Thursday, December 8, 2011

Python CSV Parsing

If you haven't realized already, I live and breathe in a command-line world. That's not even just talking about my work-related things; even when helping out helping out someone who is running Windows I will do majority of the things I need to do in the cmd prompt. Anyhow, I'm starting to ramble...

I also sporadically get some data sent to me in csv (or I will convert it to csv format). Now, if you have done this enough times, you'll obviously want to have some sort of csv parser. And what do you know, voila! I've got a simple one here for all of my command-line junkies out there!

csvreader.py is short enough to be available as a short gist on github. --My first activity on github by the way!

I'm sure you'll all find a nice way to use that. If you were curious what I ended up doing, well here's a generic code snippet: for f in `python csvreader.py tmp/b.20111208_1042.csv 0`; do echo $f; php postInfo.php /mnt/$f; done;

Cheers!