RE: This should do what you were trying to do, Roger Harris, 11-14-2004
I'm not sure either solution really does it....
by Dave, November 16, 2004 04:33
Essentially, what I want to do is be able to IMPORT *any* CSV file (without knowing its structure in advance) and then reproduce it as an HTML table, row by row thus:
<table> <tr><td>Header 1</td><td>Header 2</td><td>Header 3</td></tr> <tr><td>Value 1 </td><td>Value 2 </td><td>Value 3 </td></tr> <tr><td>Value 1 </td><td>Value 2 </td><td>Value 3 </td></tr> (...and so on...) <table>
I've tried the solutions above, and they do do the job of extracting the variables and headers, but I'm having real trouble formatting the results as a table with the headings appearing just once (unless I've missed something).
I've been playing with importing a line too and using repl(). The biggest problem, though, is what if the field contains commas, apostrophes or double quotes? This is likely to happen frequently, especially in the case of Irish names like O'Reily and indeed in addresses.
Somewhat fortunately, in the task I'm working on currently I can control how the CSV file is created and have opted to use the pipe as a delimiter which helps a bit, and I'm having to replace quotes with ` - but it doesn't look very elegant.
However, the next step will be to allow the importing of true CSV files exported from Excel and Access - including line breaks - so that will require commas.
Having said all that, I would *LOVE* to see the new version! :-)
Name E-mail optional TopicMessage:
HTTP Link: Link text: