From: Mark Van Holstyn Date: 2006-09-09T12:03:13+09:00 Subject: Re: Parsing a tab delimited file with ruby csv? ------=_Part_26390_25091564.1157770987709 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Take a look at the faster csv library On 9/8/06, Paul Lutus wrote: > > Julio Capote wrote: > > > I've been scouring the internet for hours looking for a good tutorial on > > how to parse a tab delimited file with ruby's CSV library, the most I > > know is that the library does in fact support tabs as the delimiter, I'd > > really appricieate it if someone can post a link to a tutorial or a > > quick code sample detailing how to tell csv to use tabs as a delimiter. > > For a case like this, there's really no point using the CSV library. If > tabs > are used exclusively as delimiters and do not appear in the data, and if > each line is terminated with a linefeed, parsing such a file is very, very > easy with Ruby. > > File.open("filename").each do |record| > record.split("\t").each do |field| > field.chomp! > # do something here with each field > end > end > > > Thanks! > > Any time. :) > > -- > Paul Lutus > http://www.arachnoid.com > > -- Mark Van Holstyn mvette13@gmail.com http://lotswholetime.com ------=_Part_26390_25091564.1157770987709--