Spreadsheet to Web
|
I’ve written a little app that takes a comma-separated variable (CSV) file saved from any spreadsheet on any machine, and produces a file containing the same information as an HTML table for inclusion in a web page. For the moment it’s got no options: you get a standard table format, with all the entries centred. At some point I might upgrade the app with options, but unless someone offers me money that’ll only happen if I need them myself! Written for my own use obviously, but if it’s any use to you, that’s great. |
|
This was a very quick and easy hack compared to my other apps. If you know BBC BASIC at all, you could easily edit it to do completely different tricks. I just realized that it currently defaults to overwriting the input file with its output, which is rather bad form. Will be fixed shortly. For the benefit of anyone who’s actually downloaded it, the new version will be up shortly & I’ll say here when it is. |
|
Done. By default it now sends the output file to the directory the input file came from, with filename (default) for you to edit to your heart’s content. I’ve not filetyped the file as HTML, because without header and footer, it isn’t, it’s just text. (Assuming that there was just text in the input file!) |
|
Exactly my thought on the subject, David. The next similar tool is going to be one to take a piece of text, and HTMLify it – putting in |
|
I just got fed up of putting all the tags for tables in by hand… |
|
Especially with SSI :) |
|
What’s SSI? |
|
Server Side Include, sort of pre-php tech. Commands are embedded as comments – like <!— include file blahblah —> etc etc. |
|
Ah, okay. I do that, just didn’t recognize the acronym. Also do php – now, thanks to someone on here (I wonder who that was 8~P ) |
|
just got fed up of putting all the tags for tables in by hand… Thanks this will save a bit of work – if I can remember I’ve got it:-) |
|
Now there’s a familiar problem! :) |
|
Nice work Clive. At the risk of raining on the parade, I’d just also point out that HTMLEdit has had this ability for many, many years (including various processing options during import). Also, the Web Designer’s Toolkit product (included with HTMLEdit 6) includes !WebTable which will load CSV’s and also allow spreadsheet-style editing of the resulting table, so you can apply effects, heading, insert images, merge cells etc. |
|
No risk of rain on any parade, Andrew – my stuff’s free to any good home; yours is undoubtedly better and worth every penny to folks for whom the extra functionality will make a significant difference! Horses for courses… |
|
Text to Web now also available: http://clive.semmens.org.uk/RISCOS/index.php?XP1tx2web |
|
If you look up CSV format in Wikipedia you will see that fields in quotes may contain newlines or commas. This makes parsing rather difficult. You cannot say that a record is terminated by a newline, because the newline may be inside a quoted string. You cannot say that strings are terminated by a quote because it might be the first of a pair of quotes standing for just one, as in BASIC. Anyway, here is an application , which I wrote (incorrectly) in 2007, then amended in 2015, which copes with this problem. The table in the output webpage has as many columns as the longest record. If you Adjust-click on the iconbar-icon you get to see the CSS file determining the table’s colours and format, which you can edit and resave to your own taste. |
|
I deal with commas in quoted fields in my app, because I actually had some in the first table I wanted to process. Didn’t think about newlines or double quotes, but can easily edit it for them.
Ditto with mine, of course! |
|
http://clive.semmens.org.uk/RISCOS/index.php?XP1ss2web is now updated (v.1.02) to deal with newlines and quotes in quoted fields. It’s not 100% correct, but it’s hopefully correct in all but stupid cases. If you have two (or more) consecutive double quotes within a cell of your table, the CSV output will have four (or more) of them in a row – my app will only put one in your table, not two (or more). Non-consecutive pairs are dealt with correctly – they are after all a perfectly credible requirement. Fails gracefully on stupid cases. |