From: Michael Sc Date: 2007-02-12T21:49:52+09:00 Subject: Re: embedding if statements in upto function.(newbie questio Thanks Brian, I appreciate the help. I changed the code and ran it again. 0.upto( a.size-2 ) {|i| if (a[i][2]==a[i+1][2] and a[i][0]==a[i+1][0]) then puts ( (a[i+1][3] - a[i][3]) / a[i][3] * 100 ) else puts 0 end} With this I get an error on the 3rd line of undefined method(-) for ".08 #(the first number)#":String(NoMethodError)Print was able to do the calculation without the if statements. I think I misunderstood how output in FasterCSV processes files. basically, I sorted a csv file and I was trying to do some simple math on that file. Basically here is what I need to do. I have very large csv files and I wanted to create percentage changes. Should I try to change a to an array? I have a file that looks like this x1 date1 y1 # x1 date2 y1 # ... x1 date1 y2 # x1 date2 y2 # ... x2 date1 y1 # x2 date2 y1 # I just want to returns only if columns 1 and 3 equal the next point in the column. Thanks again. Michael Brian Candler wrote: > On Mon, Feb 12, 2007 at 08:05:01PM +0900, Michael Sc wrote: >> else print 0 >> end} > > Why don't you give some sample data, and show what happens when you run > it. > Preferably make a small, standalone program which demonstrates the > problem. > Do you get an exception raised? A wrong result? > -- Posted via http://www.ruby-forum.com/.