James Gray
7/22/2008 6:23:00 PM
On Jul 22, 2008, at 1:09 PM, Li Chen wrote:
> Hi all,
Hello.
> I just try fastercsv and it works fine.
Great.
> I use the codes below to print out the first columns of the first ten
> rows. And it is OK. Question1) Is this the Ruby way to do that?
It's definitely one possible way. You could also use:
FCSV.open('test.csv') do |csv|
csv.each do |row|
puts row.first
break if csv.lineno >= 10
end
end
> Question 2)what if I want to print out the first columns of row
> 20-30?
FCSV.open('test.csv') do |csv|
csv.each do |row|
puts row.first if csv.lineno >= 20
break if csv.lineno >= 30
end
end
Hope that gives you some fresh ideas.
James Edward Gray II