CSV to HTML translation: Difference between revisions

Content deleted Content added
→‎{{header|Maxima}}: add a solution
Line 2,155: Line 2,155:
</table>
</table>
</lang>
</lang>


=={{header|Maxima}}==
<lang Maxima>infile: "input.csv";
outfile: "table.html";
instream: openr(infile);
outstream: openw(outfile);

printf(outstream, "<TABLE border=\"1\">~%");
nr: 0;
unless (line: readline(instream), line=false) do (
nr: nr + 1,
line: ssubst("&lt;", "<", line),
line: ssubst("&gt;", ">", line),
q: map(lambda([f], strim(" ", f)), split(line, ",")),
if nr=1 then printf(outstream, " <THEAD bgcolor=\"yellow\">") else printf(outstream, " <TBODY bgcolor=\"orange\">"),
printf(outstream, "<TR>"),
for k: 1 thru length(q) do (
printf(outstream, "<TD>~a</TD>", q[k])
),
printf(outstream, "</TR>"),
if nr=1 then printf(outstream, "</THEAD>~%") else printf(outstream, "</TBODY>~%")
);
printf(outstream, "</TABLE>~%");

close(instream);
close(outstream);</lang>


=={{header|ML/I}}==
=={{header|ML/I}}==