Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,72 +1,72 @@
|
|||
module csv2html {
|
||||
nl$={
|
||||
}
|
||||
Repl$=lambda$ (a$) ->{
|
||||
a$=replace$("&", "&",a$)
|
||||
a$=replace$(">", ">",a$)
|
||||
a$=replace$("""", """,a$)
|
||||
// add any other replacement here
|
||||
=replace$("<", "<",a$)
|
||||
}
|
||||
Tag$=lambda$ nl$, repl$ (a$, b$, n=4)->{
|
||||
if n>0 then
|
||||
a$=rtrim$(replace$(nl$, nl$+string$(" ", n), nl$+a$))
|
||||
if right$(a$,2)<>nl$ then a$+=nl$
|
||||
else
|
||||
if right$(a$, 2)=nl$ then if left$(a$,2)<>nl$ then a$=nl$+a$
|
||||
end if
|
||||
prop=(,) : Read ? prop // forth parameter optional (we have to initalize first with an empty array)
|
||||
p=each(prop) : prop$="" // p is an iteration object.
|
||||
while p
|
||||
prop$+=" "+repl$(prop#val$(p^))+"="+quote$(repl$(prop#val$(p^+1)))
|
||||
p=each(prop,p^+2) // start new from p^+2 (p^ is the internal counter)
|
||||
end while
|
||||
="<"+b$+prop$+">"+a$+"</"+b$+">"+nl$
|
||||
}
|
||||
|
||||
// Prepare FILE csv
|
||||
tofile$={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!
|
||||
}
|
||||
open "forHtml.csv" for wide output as #f
|
||||
Print #f, tofile$;
|
||||
close #f
|
||||
// prepare the input style for Input from file statement
|
||||
// "," - we use comma between fields
|
||||
// "." - for numbers we use dot for decimal separator
|
||||
// false - we didn't read json style strings to normal strings (so \n convert to code 13, \t to code 9)
|
||||
// true - we read strings unquote
|
||||
input with ",",".",false, true
|
||||
|
||||
// Read csv file
|
||||
i=1
|
||||
document export$=""
|
||||
Open "forHtml.csv" for wide input as #f
|
||||
while not eof(#f)
|
||||
input #f, a$, b$
|
||||
a$=repl$(a$)
|
||||
b$=repl$(b$)
|
||||
if i=1 then
|
||||
export$+=tag$(tag$(a$, "th", 0)+tag$(b$,"th", 0), "tr", 4)
|
||||
else
|
||||
export$+=tag$(tag$(a$, "td", 0)+tag$(b$,"td", 0), "tr", 4)
|
||||
end if
|
||||
i++
|
||||
end while
|
||||
close #f
|
||||
style$=tag$({TD {background-color:#ddddff; }
|
||||
thead TD {background-color:#ddffdd; text-align:center; }
|
||||
},"style",4,("type", "text/css"))
|
||||
title$= tag$("CSV to HTML translation - Extra Credit","title",0)
|
||||
Head$= tag$(title$+ style$,"head")
|
||||
html$={<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">}+nl$+tag$(head$+tag$(tag$(export$, "table"), "body"), "html")
|
||||
clipboard html$
|
||||
Report html$
|
||||
Print "Press Esc to exit browser"
|
||||
browser "about: "+html$
|
||||
nl$={
|
||||
}
|
||||
Repl$=lambda$ (a$) ->{
|
||||
a$=replace$("&", "&",a$)
|
||||
a$=replace$(">", ">",a$)
|
||||
a$=replace$("""", """,a$)
|
||||
// add any other replacement here
|
||||
=replace$("<", "<",a$)
|
||||
}
|
||||
Tag$=lambda$ nl$, repl$ (a$, b$, n=4)->{
|
||||
if n>0 then
|
||||
a$=rtrim$(replace$(nl$, nl$+string$(" ", n), nl$+a$))
|
||||
if right$(a$,2)<>nl$ then a$+=nl$
|
||||
else
|
||||
if right$(a$, 2)=nl$ then if left$(a$,2)<>nl$ then a$=nl$+a$
|
||||
end if
|
||||
prop=(,) : Read ? prop // forth parameter optional (we have to initalize first with an empty array)
|
||||
p=each(prop) : prop$="" // p is an iteration object.
|
||||
while p
|
||||
prop$+=" "+repl$(prop#val$(p^))+"="+quote$(repl$(prop#val$(p^+1)))
|
||||
p=each(prop,p^+2) // start new from p^+2 (p^ is the internal counter)
|
||||
end while
|
||||
="<"+b$+prop$+">"+a$+"</"+b$+">"+nl$
|
||||
}
|
||||
|
||||
// Prepare FILE csv
|
||||
tofile$={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!
|
||||
}
|
||||
open "forHtml.csv" for wide output as #f
|
||||
Print #f, tofile$;
|
||||
close #f
|
||||
// prepare the input style for Input from file statement
|
||||
// "," - we use comma between fields
|
||||
// "." - for numbers we use dot for decimal separator
|
||||
// false - we didn't read json style strings to normal strings (so \n convert to code 13, \t to code 9)
|
||||
// true - we read strings unquote
|
||||
input with ",",".",false, true
|
||||
|
||||
// Read csv file
|
||||
i=1
|
||||
document export$=""
|
||||
Open "forHtml.csv" for wide input as #f
|
||||
while not eof(#f)
|
||||
input #f, a$, b$
|
||||
a$=repl$(a$)
|
||||
b$=repl$(b$)
|
||||
if i=1 then
|
||||
export$+=tag$(tag$(a$, "th", 0)+tag$(b$,"th", 0), "tr", 4)
|
||||
else
|
||||
export$+=tag$(tag$(a$, "td", 0)+tag$(b$,"td", 0), "tr", 4)
|
||||
end if
|
||||
i++
|
||||
end while
|
||||
close #f
|
||||
style$=tag$({TD {background-color:#ddddff; }
|
||||
thead TD {background-color:#ddffdd; text-align:center; }
|
||||
},"style",4,("type", "text/css"))
|
||||
title$= tag$("CSV to HTML translation - Extra Credit","title",0)
|
||||
Head$= tag$(title$+ style$,"head")
|
||||
html$={<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">}+nl$+tag$(head$+tag$(tag$(export$, "table"), "body"), "html")
|
||||
clipboard html$
|
||||
Report html$
|
||||
Print "Press Esc to exit browser"
|
||||
browser "about: "+html$
|
||||
}
|
||||
csv2html
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue