CSV to HTML translation: Difference between revisions
Content added Content deleted
(CoffeeScript implementation) |
|||
Line 1,035: | Line 1,035: | ||
<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></lang> |
</table></lang> |
||
=={{header|Lua}}== |
|||
<lang lua>FS = "," -- field separator |
|||
csv = [[ |
|||
Character,Speech |
|||
The multitude,The messiah! Show us the messiah! |
|||
Brians mother,<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry> |
|||
The multitude,Who are you? |
|||
Brians mother,I'm his mother; that's who! |
|||
The multitude,Behold his mother! Behold his mother! |
|||
]] |
|||
html = { "<table>" } |
|||
for line in string.gmatch( csv, "(.-\n)" ) do |
|||
str = "<tr>" |
|||
for field in string.gmatch( line, "(.-)["..FS.."?\n?]" ) do |
|||
str = str .. "<td>" .. field .. "</td>" |
|||
end |
|||
str = str .. "</tr>" |
|||
html[#html+1] = str; |
|||
end |
|||
html[#html+1] = "</table>" |
|||
for _, line in pairs(html) do |
|||
print(line) |
|||
end</lang> |
|||
<pre><table> |
|||
<tr><td>Character</td><td>Speech</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>The multitude</td><td>Who are you</td><td></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> |
|||
</pre> |
|||
=={{header|MATLAB}}== |
=={{header|MATLAB}}== |