CSV to HTML translation: Difference between revisions
Content deleted Content added
→[[CSV to HTML translation#ALGOL 68]]: rename varibles. |
m changed ALL <pre> and <lang html*> to <lang html5> |
||
Line 65: | Line 65: | ||
table.tmplt: |
table.tmplt: |
||
<lang |
<lang html5><table> |
||
@@TABLE@@ |
@@TABLE@@ |
||
<tr> |
<tr> |
||
Line 75: | Line 75: | ||
Output: |
Output: |
||
<lang |
<lang html5><table> |
||
<tr> |
<tr> |
||
<td>Character</td> |
<td>Character</td> |
||
Line 174: | Line 174: | ||
lmth</lang> |
lmth</lang> |
||
Output: |
Output: |
||
<lang html5> |
<lang html5><HTML> |
||
<HTML> |
|||
<HEAD> |
<HEAD> |
||
<TITLE>CSV to HTML translation - Extra Credit</TITLE> |
<TITLE>CSV to HTML translation - Extra Credit</TITLE> |
||
Line 193: | Line 192: | ||
</TABLE> |
</TABLE> |
||
</BODY> |
</BODY> |
||
</HTML> |
</HTML></lang> |
||
</lang> |
|||
=={{header|C}}== |
=={{header|C}}== |
||
This produces a full bare html (tidy gives 1 warning) with styles embedded but not |
This produces a full bare html (tidy gives 1 warning) with styles embedded but not |
||
Line 291: | Line 288: | ||
}</lang> |
}</lang> |
||
Output: |
Output: |
||
< |
<lang html5><html><head><title>CSV converted into HTML</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css"><!--th {font-weight:bold;text-align:left;background-color:yellow}table,td,th {border:1px solid #000;border-collapse:collapse}td {background-color:cyan}td,th {padding:5px}//--></style></head><body><table summary="data"><tr><th>Character</th><th>Speech</th></tr><tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr><tr><td>Brians mother</td><td><angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry></td></tr><tr><td>The multitude</td><td>Who are you?</td></tr><tr><td>Brians mother</td><td>I'm his mother; that's who!</td></tr><tr><td>The multitude</td><td>Behold his mother! Behold his mother!</td></tr></table></body></html></nowiki></lang> |
||
=={{header|C++}}== |
=={{header|C++}}== |
||
Line 327: | Line 324: | ||
}</lang> |
}</lang> |
||
Output: |
Output: |
||
<lang |
<lang html5> |
||
<TABLE> |
<TABLE> |
||
<TR><TD>Character</TD><TD>Speech</TD></TR> |
<TR><TD>Character</TD><TD>Speech</TD></TR> |
||
Line 383: | Line 380: | ||
Output: |
Output: |
||
< |
<lang html5><table cellspacing="0"> |
||
<thead> |
|||
<th scope="col">Character</th> |
|||
<th scope="col">Speech</th> |
|||
</thead> |
|||
<tbody> |
|||
<th scope="row">The multitude</th> |
|||
<td>The messiah! Show us the messiah!</td> |
|||
<th scope="row">Brians mother</th> |
|||
<td><angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry></td> |
|||
<th scope="row">The multitude</th> |
|||
<td>Who are you?</td> |
|||
<th scope="row">Brians mother</th> |
|||
<td>I'm his mother; that's who!</td> |
|||
<th scope="row">The multitude</th> |
|||
<td>Behold his mother! Behold his mother!</td> |
|||
</tbody> |
|||
</table></lang> |
|||
</pre> |
|||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
Line 593: | Line 589: | ||
'''Basic output:''' |
'''Basic output:''' |
||
<lang |
<lang html5> |
||
<!DOCTYPE html |
<!DOCTYPE html |
||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
||
Line 626: | Line 622: | ||
'''Extra credit output:''' |
'''Extra credit output:''' |
||
<lang |
<lang html5> |
||
<!DOCTYPE html |
<!DOCTYPE html |
||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
||
Line 736: | Line 732: | ||
}</lang> |
}</lang> |
||
Standard output in table.html: |
Standard output in table.html: |
||
<lang |
<lang html5><table> |
||
<table> |
|||
<tr><td>Character</td><td>Speech</td></tr> |
<tr><td>Character</td><td>Speech</td></tr> |
||
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
||
Line 747: | Line 742: | ||
</lang> |
</lang> |
||
Output with -h: (Notice <th> tag on first row. Otherwise output is identical.) |
Output with -h: (Notice <th> tag on first row. Otherwise output is identical.) |
||
<lang |
<lang html5><table> |
||
<table> |
|||
<tr><th>Character</th><th>Speech</th></tr> |
<tr><th>Character</th><th>Speech</th></tr> |
||
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
||
Line 821: | Line 815: | ||
'''Basic output:''' |
'''Basic output:''' |
||
<div style="height:30ex;overflow:scroll;"><lang |
<div style="height:30ex;overflow:scroll;"><lang html5><html> |
||
<head> |
<head> |
||
<title>Basic</title> |
<title>Basic</title> |
||
Line 843: | Line 837: | ||
'''Extra Credit output:''' |
'''Extra Credit output:''' |
||
<div style="height:30ex;overflow:scroll;"><lang |
<div style="height:30ex;overflow:scroll;"><lang html5><html> |
||
<head> |
<head> |
||
<title>Extra Credit</title> |
<title>Extra Credit</title> |
||
Line 905: | Line 899: | ||
'''Basic output:''' |
'''Basic output:''' |
||
<div style="height:30ex;overflow:scroll;"><lang |
<div style="height:30ex;overflow:scroll;"><lang html5><html> |
||
<head> |
<head> |
||
<title>Basic</title> |
<title>Basic</title> |
||
Line 946: | Line 940: | ||
'''Extra Credit output:''' |
'''Extra Credit output:''' |
||
<div style="height:30ex;overflow:scroll;"><lang |
<div style="height:30ex;overflow:scroll;"><lang html5><html> |
||
<head> |
<head> |
||
<title>Extra Credit</title> |
<title>Extra Credit</title> |
||
Line 1,022: | Line 1,016: | ||
;Output: |
;Output: |
||
<div style="height:30ex;overflow:scroll;"><lang |
<div style="height:30ex;overflow:scroll;"><lang html5><table> |
||
<tr> |
<tr> |
||
<td>Character</td> |
<td>Character</td> |
||
Line 1,075: | Line 1,069: | ||
Output: |
Output: |
||
<lang |
<lang html5><TABLE> |
||
<THEAD> |
<THEAD> |
||
<TR><TD>Character</TD><TD>Speech</TD></TR> |
<TR><TD>Character</TD><TD>Speech</TD></TR> |
||
Line 1,128: | Line 1,122: | ||
1 makeHTMLtablefromCSV CSVstrng</lang> |
1 makeHTMLtablefromCSV CSVstrng</lang> |
||
HTML output: |
HTML output: |
||
<lang |
<lang html5><table> |
||
<tr><th>Character</th><th>Speech</th></tr> |
<tr><th>Character</th><th>Speech</th></tr> |
||
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
||
Line 1,164: | Line 1,158: | ||
end</lang> |
end</lang> |
||
< |
<lang html5><table> |
||
<tr><td>Character</td><td>Speech</td></tr> |
<tr><td>Character</td><td>Speech</td></tr> |
||
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
||
Line 1,171: | Line 1,165: | ||
<tr><td>Brians mother</td><td>I'm his mother; that's who!</td></tr> |
<tr><td>Brians mother</td><td>I'm his mother; that's who!</td></tr> |
||
<tr><td>The multitude</td><td>Behold his mother! Behold his mother!</td></tr> |
<tr><td>The multitude</td><td>Behold his mother! Behold his mother!</td></tr> |
||
</table> |
</table></lang> |
||
</pre> |
|||
=={{header|MATLAB}}== |
=={{header|MATLAB}}== |
||
Line 1,254: | Line 1,247: | ||
Ouput: |
Ouput: |
||
<lang |
<lang html5>>> csvToHTML(data) |
||
ans = |
ans = |
||
Line 1,364: | Line 1,357: | ||
Sample html output: |
Sample html output: |
||
<lang |
<lang html5><table> |
||
<tr> |
<tr> |
||
<td>Character</td> <td>Speech</td> |
<td>Character</td> <td>Speech</td> |
||
Line 1,486: | Line 1,479: | ||
Output: |
Output: |
||
<lang |
<lang html5><table> |
||
<thead> |
<thead> |
||
<tr> |
<tr> |
||
Line 1,539: | Line 1,532: | ||
Output (with a command-line argument): |
Output (with a command-line argument): |
||
<lang |
<lang html5><table> |
||
<tr><th>Character</th><th>Speech</th></tr> |
<tr><th>Character</th><th>Speech</th></tr> |
||
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
||
Line 1,559: | Line 1,552: | ||
(prinl) ) ) )</lang> |
(prinl) ) ) )</lang> |
||
Output: |
Output: |
||
<lang |
<lang html5><table class="myStyle"> |
||
<tr><td>Character</td><td>Speech</td></tr> |
<tr><td>Character</td><td>Speech</td></tr> |
||
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
||
Line 1,578: | Line 1,571: | ||
(prinl) ) ) ) )</lang> |
(prinl) ) ) ) )</lang> |
||
Output: |
Output: |
||
<lang |
<lang html5><table class="myStyle"><tr><th>Character</th><th>Speech</th></tr> |
||
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
||
<tr><td>Brians mother</td><td><angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry></td></tr> |
<tr><td>Brians mother</td><td><angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry></td></tr> |
||
Line 1,592: | Line 1,585: | ||
</lang> |
</lang> |
||
Output: |
Output: |
||
<lang |
<lang html5><table> |
||
<table> |
|||
<colgroup> |
<colgroup> |
||
<col/> |
<col/> |
||
Line 1,605: | Line 1,597: | ||
<tr><td>Brians mother</td><td>I'm his mother; that's who! </td></tr> |
<tr><td>Brians mother</td><td>I'm his mother; that's who! </td></tr> |
||
<tr><td>The multitude</td><td>Behold his mother! Behold his mother! </td></tr> |
<tr><td>The multitude</td><td>Behold his mother! Behold his mother! </td></tr> |
||
</table> |
</table></lang> |
||
</lang> |
|||
===Extra credit solution=== |
===Extra credit solution=== |
||
<lang Powershell> |
<lang Powershell> |
||
Line 1,620: | Line 1,611: | ||
</lang> |
</lang> |
||
Output: |
Output: |
||
<lang |
<lang html5> |
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
||
<html xmlns="http://www.w3.org/1999/xhtml"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
||
Line 1,702: | Line 1,693: | ||
</lang> |
</lang> |
||
OutPut : |
OutPut : |
||
<lang |
<lang html5><TABLE> |
||
<TR> |
<TR> |
||
<TD>Character</TD><TD>Speech</TD> |
<TD>Character</TD><TD>Speech</TD> |
||
Line 1,816: | Line 1,807: | ||
</lang> |
</lang> |
||
Output : |
Output : |
||
<lang |
<lang html5><TABLE> |
||
<THEAD> |
<THEAD> |
||
<TR> |
<TR> |
||
Line 1,879: | Line 1,870: | ||
'''Sample HTML output''' |
'''Sample HTML output''' |
||
<lang |
<lang html5><TABLE summary="csv2html program output"> |
||
<TBODY><TR><TD>Character</TD><TD>Speech</TD></TR></TBODY> |
<TBODY><TR><TD>Character</TD><TD>Speech</TD></TR></TBODY> |
||
<TBODY><TR><TD>The multitude</TD><TD>The messiah! Show us the messiah!</TD></TR></TBODY> |
<TBODY><TR><TD>The multitude</TD><TD>The messiah! Show us the messiah!</TD></TR></TBODY> |
||
Line 1,924: | Line 1,915: | ||
The raw HTML would not render correctly through the wiki interface but shows a suitably coloured table with cell borders. |
The raw HTML would not render correctly through the wiki interface but shows a suitably coloured table with cell borders. |
||
--> |
--> |
||
<lang |
<lang html5><TABLE border="1" summary="csv2html extra program output"> |
||
<THEAD bgcolor="yellow"><TR><TD>Character</TD><TD>Speech</TD></TR></THEAD> |
<THEAD bgcolor="yellow"><TR><TD>Character</TD><TD>Speech</TD></TR></THEAD> |
||
<TBODY bgcolor="orange"><TR><TD>The multitude</TD><TD>The messiah! Show us the messiah!</TD></TR></TBODY> |
<TBODY bgcolor="orange"><TR><TD>The multitude</TD><TD>The messiah! Show us the messiah!</TD></TR></TBODY> |
||
Line 1,956: | Line 1,947: | ||
end |
end |
||
puts "</table>"</lang>Sample output:<lang |
puts "</table>"</lang>Sample output:<lang html5><table summary="csv2html program output"> |
||
<tr><th>Character</th><th>Speech</th></tr> |
<tr><th>Character</th><th>Speech</th></tr> |
||
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
||
Line 2,041: | Line 2,032: | ||
}]</lang> |
}]</lang> |
||
Output: |
Output: |
||
<lang |
<lang html5><table border="1" summary="csv2html program output"> |
||
<tr bgcolor="yellow"><td>Character</td><td>Speech</td></tr> |
<tr bgcolor="yellow"><td>Character</td><td>Speech</td></tr> |
||
<tr bgcolor="orange"><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
<tr bgcolor="orange"><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
||
Line 2,091: | Line 2,082: | ||
</lang> |
</lang> |
||
=== Output (source code) === |
=== Output (source code) === |
||
<lang |
<lang html5><!DOCTYPE html system> |
||
<!DOCTYPE html system> |
|||
<html> |
<html> |
||
<head> |
<head> |