From: "NAKAMURA, Hiroshi" Date: 2002-02-18T14:10:00+09:00 Subject: Re: (CSV) text file processing... Hi all, > From: Paul Brannan [mailto:paul@atdesk.com] > Sent: Thursday, February 14, 2002 2:00 AM > There's also a CSV library on the RAA at: > http://www.ruby-lang.org/en/raa-list.rhtml?name=csv Thank you for introducing it. I also thanks to authors of Ruby Developer's Guide. > It handles input like: > foo,bar,1,2,"this is a comma (,) test",more text Yes. And also CR-LF's in a cell. I recently added iterator interfaces to csv module like; CSV.open( "csv.csv", "w" ) do | writer | writer << [ "1", "2", "3" ] writer << [ "4", "5", "6" ] end CSV.open( "csv.csv", "r" ) do | row | p row.to_a # Should stop parsing at first line unless reading/parsing # rest of file even if it's 1G size. break end You can parse socket like this; svr = TCPServer.new( ... ) s = svr.accept CSV::Reader.parse( s ) do | row | p row firstCell = row[ 0 ] break if !firstCell.isNull and firstCell.data == 'quit' end Old native interfaces must also work. You can get new version from http://www.ruby-lang.org/~knu/cgi-bin/cvsweb.cgi/lib/csv/ Regards, // NaHi