CSV to HTML translation: Difference between revisions
Content added Content deleted
Line 3,271: | Line 3,271: | ||
=={{header|Nanoquery}}== |
=={{header|Nanoquery}}== |
||
<lang nanoquery>// a method that converts a csv row into a html table row as a string |
<lang nanoquery>// a method that converts a csv row into a html table row as a string |
||
def toHtmlRow( |
def toHtmlRow(record, tag) |
||
htmlrow = "\t<tr>\n" |
|||
// loop through the values in the current csv row |
// loop through the values in the current csv row |
||
for |
for i in range(1, len(record)) |
||
htmlrow = htmlrow + "\t\t<" + tag + ">" + (record ~ i) + "</" + tag + ">\n" |
|||
end for |
end for |
||
return |
return htmlrow + "\t</tr>\n" |
||
end def |
end def |
||
// get the name of the csv file then open it |
// get the name of the csv file then open it |
||
print "filename: " |
print "filename: " |
||
input |
input fname |
||
open |
open fname |
||
// allocate a string to hold the table |
// allocate a string to hold the table |
||
htmltable = "<table>\n" |
|||
// add the column names to the table (#0 returns column names as a record object |
// add the column names to the table (#0 returns column names as a record object) |
||
htmltable = (htmltable + toHtmlRow(#0, "th")) |
|||
// add all other rows to the table |
// add all other rows to the table |
||
for |
for i in range(1, $dbsize) |
||
htmltable = (htmltable + toHtmlRow(#i, "td")) |
|||
end for |
end for |
||
// close the html table |
// close the html table |
||
htmltable = htmltable+"</table>" |
|||
println |
println htmltable</lang> |
||
=={{header|NetRexx}}== |
=={{header|NetRexx}}== |