TSV to HTML
Paddy
paddy3118 at netscape.net
Thu Jun 1 01:31:15 EDT 2006
Brian wrote:
> First let me say that I appreciate the responses that everyone has
> given.
>
> A friend of mine is a ruby programmer but knows nothing about python.
> He gave me the script below and it does exactly what I want, only it is
> in Ruby. Not knowing ruby this is greek to me, and I would like to
> re-write it in python.
>
> I ask then, is this essentially what others here have shown me to do,
> or is it in a different vein all together?
>
Leif's Python example uses the csv module which understands a lot more
about the peculiarities of the CSV/TSV formats.
The Ruby example prepends a <style>...</style> block.
The Ruby example splits each line to form a table row and each row on
tabs, to form the cells.
The thing about TSV/CSV formats is that their is no one format. you
need to check how your TSV creator generates the TSV file:
Does it put quotes around text fields?
What kind of quotes?
How does it represent null fields?
Might you get fields that include newlines?
- P.S. I'm not a Ruby programmer, just read the source ;-)
More information about the Python-list
mailing list