Neil's News

+ 2010
+ 2009
+ 2008
+ 2007
+ 2006
- 2005
 Shell Acoustics
 Context Menus
 Security Lecture
 Unfortunate Typo
 Logging Out
 Switch
 Through the Looking Glass
 Scotland Video
 Comma Separated Values
 OU-M880 (Soft Eng)
 Cycling Britain
 Hidden Costs
 Hiring
 Golden
 Style vs Substance
 Bess
 Ajax Content
 DHTML Client
 Over There
 Content Hijacking
 Raw Statistics
 Trying to Fail
 SETI@home 2500
 Security Separation
 Gamma Ray Bursts
 Fishy Behaviour
 Moo Browser
 Caption this Photo
 All Good Things
 Dalek
 Moo Direction
 Open University
 OU-M865 (Projects)
 OU-M876 (Data)
 OU-M886 (Security)
 OU-M878 (Objects)
 OU-M874 (Java)
 OU-M873 (UI)
 Einstein's Riddle
 Glowing Books
 Hogmanay
+ 2004
+ 2003
+ 2002

Comma Separated Values

17 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.

< Previous | Next >

 
-------------------------------------