CSV to HTML

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"; } ?>


This entry was posted in Articles and tagged , , , , , . Bookmark the permalink.

3 Responses to CSV to HTML

  1. jonathan says:

    what fun!

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

    pretty cool script :)

  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.

  3. Keegan Carruthers-Smith says:

    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 ;)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>