From: William James Date: 2005-10-31T00:02:06+09:00 Subject: Re: Faster CSV parsing Robert Klemme wrote: > William James wrote: > > Gavin Kistner wrote: > >> On Oct 29, 2005, at 10:07 PM, William James wrote: > >>> ## Read, parse, and create csv records. > >>> > >>> # The program conforms to the csv specification at this site: > >>> # http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm > >>> # The only extra is that you can change the field-separator. > >>> # For a field-separator other than a comma, for example > >>> # a semicolon: > >>> # Csv.fs=";" > >>> # > >>> # After a record has been read and parsed, > >>> # Csv.string contains the record in raw string format. > >> > >> Thanks for sharing this. You claim 'faster' CSV parsing. Faster than > >> what, > > > > Than Ruby's standard-lib csv.rb. > > > >> and by how much? Got any benchmark results to share? > > > > For my test file of 1,964,211 bytes, it's about 6.4 times as fast. > > I didn't look too closely at it nor did I test it but your use of class > variables seems not necessary here. I'd prefer to transform them into > instance variables. Makes your code much more robust... > > Kind regards > > robert If anyone wants to make it more robust, he is free to do so. I have little need for csv parsing, and I don't want to spend much more time on this. The people on Ruby Core who are trying to speed up CSV parsing could use this as a starting point.