From: James Edward Gray II Date: 2007-02-07T04:51:39+09:00 Subject: Re: How do you get the rows out of FasterCSV? On Feb 6, 2007, at 12:52 PM, Thisforum Isspammable wrote: > > Thanks, works great!! > > If I want to parse some columns as floats, some as ints, and leave the > rest alone, is this the best way to do it? > > table = FCSV.parse(open(csv_filename), > :headers => true, > :converters => lambda { |f, info| > case info.header > when "NUM" > f.to_i > when "RATE" > f.to_f > else > f > end > }) Instead of: FCSV.parse(open(csv_filename) ... ) Use: FCSV.read(csv_filename ... ) Your converters work fine though, yes. If you numbers can be recognized by some built-in converters, you might even be able to get away with FCSV.read(csv_filename, :headers => true, :converters => :numeric) > How do I write the finished file? My attempts appear without > headers in > the csv file? I would use: File.open("path/to/file", "w") { |f| f.puts table } Hope that helps. James Edward Gray II