Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/CSV-to-HTML-translation/J/csv-to-html-translation-1.j
Normal file
22
Task/CSV-to-HTML-translation/J/csv-to-html-translation-1.j
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
require 'strings tables/csv'
|
||||
encodeHTML=: ('&';'&';'<';'<';'>';'>')&stringreplace
|
||||
|
||||
tag=: adverb define
|
||||
'starttag endtag'=.m
|
||||
(,&.>/)"1 (starttag , ,&endtag) L:0 y
|
||||
)
|
||||
|
||||
markupCells=: ('<td>';'</td>') tag
|
||||
markupHdrCells=: ('<th>';'</th>') tag
|
||||
markupRows=: ('<tr>';'</tr>',LF) tag
|
||||
markupTable=: (('<table>',LF);'</table>') tag
|
||||
|
||||
makeHTMLtablefromCSV=: verb define
|
||||
0 makeHTMLtablefromCSV y NB. default left arg is 0 (no header row)
|
||||
:
|
||||
t=. fixcsv encodeHTML y
|
||||
if. x do. t=. (markupHdrCells@{. , markupCells@}.) t
|
||||
else. t=. markupCells t
|
||||
end.
|
||||
;markupTable markupRows t
|
||||
)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
tag=: adverb def '[: (,&.>/)"1 m&(0&{::@[ , 1&{::@[ ,~ ]) L:0@]'
|
||||
makeHTMLtablefromCSV6=: 0&$: : ([: ; markupTable@markupRows@([ markupCells`(markupHdrCells@{. , markupCells@}.)@.[ fixcsv@encodeHTML))
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
CSVstrng=: noun define
|
||||
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!
|
||||
)
|
||||
1 makeHTMLtablefromCSV CSVstrng
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<table>
|
||||
<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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue