|
Comma Separated Values17 October 2005 The last assignments are in, the last exam written, that's me finished University -- except for next year's dissertation. Woo! To celebrate, I took the day off work (sorry, I think half my readers just fainted) and took the train into Inverness to watch the long-awaited BDM on opening night. There were less than a dozen people in the theater, and when the lights came back on, it was empty. So not exactly the social event I'd been hoping for. Still, it was an excellent movie. First time I've been out in more than two and a half years. The best part was Serenity's legs. On final approach you could see them clawing at empty air, searching for the ground. Oh yeah, definitely have to say it was her legs. Her legs, and where her legs meet her hull. Actually, that whole area. (Note to self: I really ought to stop posting things which only a few people will understand, and everyone else will badly misconstrue. One day this will get me in trouble. Again.) Anyway, in an attempt to keep this site from sliding down the slippery slope to blog-dom, here's some code: Comma Separated Values (CSV) is a nice simple format for storing tables. Lots of applications export to CSV and anyone can access the CSV data using any spreadsheet application. Most programming languages have libraries which provide support for parsing and writing CSV files. Unfortunately many of these libraries are heavy-weight monsters which won't let you do simple things like, you know, parsing CSV. They often want to take over the whole file I/O process too. Here are some simple, lightweight CSV functions for single-lines of data. No bells and whistles, they just do what is needed. Moo versions can be found on Moo Canada (to_CSV, from_CSV). PHP versions can be found in the user comments of the heavy-weight fputcsv and fgetcsv functions. |