How to resolve the algorithm CSV to HTML translation step by step in the TUSCRIPT programming language
How to resolve the algorithm CSV to HTML translation step by step in the TUSCRIPT programming language
Table of Contents
Problem Statement
Consider a simplified CSV format where all rows are separated by a newline and all columns are separated by commas. No commas are allowed as field data, but the data may contain other characters and character sequences that would normally be escaped when converted to HTML
Create a function that takes a string representation of the CSV data and returns a text string of an HTML table representing the CSV data. Use the following data as the CSV text to convert, and show your output.
Optionally allow special formatting for the first row of the table as if it is the tables header row
(via preferably; CSS if you must).
Let's start with the solution:Step by Step solution about How to resolve the algorithm CSV to HTML translation step by step in the TUSCRIPT programming language
Source code in the tuscript programming language
$$ MODE TUSCRIPT
MODE DATA
$$ csv=*
Character,Speech
The multitude,The messiah! Show us the messiah!
Brians mother,
$$ BUILD X_TABLE txt2html=*
<< <
>> >
$$ MODE TUSCRIPT
file="brian.html"
ERROR/STOP CREATE (file,FDF-o,-std-)
csv=EXCHANGE (csv,txt2html)
x=SPLIT (csv,":,:",row1,row2)
ACCESS html: WRITE/ERASE/RECORDS/UTF8 $file s,html
WRITE html htmlhead
LOOP n,td1=row1,td2=row2
IF (n==1) THEN
row=CONCAT ("
"
ENDACCESS/PRINT html
")
ELSE
row=CONCAT ("",td1," ",td2," ")
ENDIF
WRITE html row
ENDLOOP
WRITE html "",td1," ",td2,"
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!
You may also check:How to resolve the algorithm Numerical integration step by step in the C programming language
You may also check:How to resolve the algorithm Even or odd step by step in the Icon and Unicon programming language
You may also check:How to resolve the algorithm Compiler/syntax analyzer step by step in the ATS programming language
You may also check:How to resolve the algorithm Even or odd step by step in the Plain English programming language
You may also check:How to resolve the algorithm Draw a cuboid step by step in the Factor programming language