Tim Keller

Web, IT, Telecoms, Development, Networks, Photography, Life.

CSV to HTML

with 3 comments

I produce websites for a lot of school’s in and around Cape Town. It’s something I started doing when I was in High School, and it’s kinda stuck.

Last night I received a Word document with pages of teacher’s names and email addresses for a website. As I looked at it I imagined the huge amount of time I was about to waste either in a WYSIWYG editor or copying and pasting HTML tags.

Then I remembered that I had a B.Sc and more than 2 brain cells. I moved the Word Table to iWork Numbers (Excel would have worked just as well), exported the file as a CSV document, pulled open Textedit and wrote a quick PHP-CLI script to suck in the CSV and output the relevant HTML.

Hope it’s useful to someone else out there!

#!/usr/bin/php
$job: ".htmlspecialchars($name)."
n"; } ?>


Written by Tim Keller

January 19th, 2009 at 8:06 pm

Posted in Programming

Tagged with , , , ,

3 Responses to 'CSV to HTML'

Subscribe to comments with RSS or TrackBack to 'CSV to HTML'.

  1. what fun!

    more than 2 brain cells, haha – thats about right.

    pretty cool script :)

    jonathan

    19 Jan 09 at 8:17 pm

  2. Be glad you received it in a nice format. Plenty times people have sent me PDFs for which text extraction screws things up. Scripting is still doable (and I do it cause it’s still quicker than manual), but a PITA.

    Marco Gallotta

    19 Jan 09 at 11:04 pm

  3. Be glad that your CSV is in that format. You can have things in quotes, then writing your own parser can be a bit of a bitch.

    You should of used the standard python module CSV ;)

    Keegan Carruthers-Smith

    20 Jan 09 at 7:19 am

Leave a Reply