From: James Edward Gray II Date: 2007-04-27T01:37:51+09:00 Subject: Re: csv next and previous help On Apr 26, 2007, at 11:00 AM, Geoff wrote: > It helps a lot! Good. > Still getting an error though. I bet we can fix that. > Here is the code I used and the error I got: > > require 'rubygems' > require 'faster_csv' > > parsed = FCSV.parse('C:/ruby/work/FRIEDEXT01.LFP', 'r') Let's try changing the above line to: parsed = FCSV.read('C:/ruby/work/FRIEDEXT01.LFP') > changed = parsed.inject(Array.new) do |rows, row| > if row[2] == "C" and (d_row = rows.reverse.find { |r| r[2] == "D" }) > d_row[2] = "P" > end > rows << row > end > puts changed.map { |r| r.to_csv } Hope that helps. James Edward Gray II