From: John Mcleod Date: 2009-08-18T21:53:36+09:00 Subject: Re: CSV import to hash to compare with database James, Thank you for the example code. It's funny, I found an old post of yours from 2005. h = Hash.new(0) file = FasterCSV.read(filename)[1..-1].each { |row| h[row[0]] += 1 } I've tested it and it seems to work. I will however, check out the documentation and your test code. This is step 1 though. Next, populate a hash with data from the database comparing data from the CSV file and making a editable CSV grid (post to rails forum). I'm not done yet. Thanks again. JohnM James Gray wrote: > On Aug 17, 2009, at 11:56 AM, John Mcleod wrote: > >> Mr. Gray, > > You can stick with James. I'm not that old yet. ;) > >> Thank you for the quick reply. > > Sure. Happy to help. > >> Could you please point me to a good 'FasterCSV' resource with some >> examples? > > The documentation is pretty thorough: > > http://fastercsv.rubyforge.org/ > > and the tests show usage: > > http://fastercsv.rubyforge.org/svn/trunk/test/ > > If your needs are simple though, maybe this code is all you need: > > FCSV.foreach( path, :headers => true, > :header_converters => :symbol ) do |row| > YourARModelClass.create!(row.to_hash) > end > > Hopefully that at least gets you started. > > James Edward Gray II -- Posted via http://www.ruby-forum.com/.