Topic: Anyone have a handle on a generic CSV parser?

Hey all,

I have a lot of CSV importing to do.  And, the CSV data is in different formats!

So, I'd like to either find (preferable) or build (acceptable) a generic CSV parser.  The idea would be that the CSV parser would need to support the following items:

, separated
| separated
\t (tab) separated

with the data inside and outside quotes.  Ideally, it will read a string or a file with CSV data in it, and return an array of hashes with the header row as the attributes. 

I've seen some stuff out there, but nothing that looks like it will handle multiple different types of separators on the fly.

Anyone have any suggestions, good or otherwise, before I spend the next 3 days writing a CSV parser?



Re: Anyone have a handle on a generic CSV parser?

Have you looked at the Ruby Lib CSV?  It comes with Ruby, just require 'csv'.