From: Rafael George Date: 2007-02-27T04:08:06+09:00 Subject: Re: Parsing CSV Thanks, James and the other guys i think i found the solution for my problem :-) On 2/26/07, James Edward Gray II wrote: > On Feb 26, 2007, at 11:48 AM, James Edward Gray II wrote: > > > On Feb 26, 2007, at 8:45 AM, Rafael George wrote: > > > >> passvalues = [] > >> i = 0 > >> IO.foreach(fsource) do |line| > >> cols = [] > >> cols=CSV::parse_line line.chomp > >> sourceval = cols[scomp_args[0]] + " " + cols[scomp_args[1]] > >> IO.foreach(tdest) do |line| > >> tcols = [] > >> tcols=CSV::parse_line line.chomp > >> testval = tcols[tcomp_args[0]] + " " + tcols[tcomp_args[1]] > >> if sourceval == testval > >> passvalues[i] = sourceval > >> i += 1 > >> end > >> end > >> end > > > > The direct translation of this code to FasterCSV is: > > > > passvalues = Array.new > > FCSV.foreach(fsource) |s_row| > > source = s_row[scomp_args[0]..scomp_args[1]].join(" ") > > FCSV.foreach(tdest) |t_row| > > if source == t_row[scomp_args[0]..scomp_args[1]].join(" ") > > passvalues << source > > break # performance enhancement > > > end > > end > > end > > James Edward Gray II > > -- Grimoire Guru SourceMage GNU/Linux