From: Alice Gheorghiu Date: 2009-05-16T09:25:18+09:00 Subject: Re: Flat CSV to Relational DB Jeremy Hinegardner wrote: > On Fri, Nov 10, 2006 at 03:08:11AM +0900, Michael Guterl wrote: >> On 11/8/06, Jeremy Hinegardner wrote: > > [...] > >> >Sometimes I've had to have ruby reprocess the csv file to get into the >> >quoted format that the db import command format, but in the overall >> >time, it was actually faster to process the CSV file and have the db >> >load it natively than to have ruby process the CSV file and do the >> >inserts via ActiveRecord or the DBI interface. >> > >> I do like this suggestion, do all the CSV manipulations, then pass off >> to the appropriate DB command. I will have to investigate these >> options further. > > Glad to help. Let us know how it turns out. > > enjo, > > -jeremy Hi Jeremy: Can you please elaborate on how you call natively load data infile from a ruby file ? I really need good performance and I cannot get it as you said by using active records or DBI. The piece of code that is slow is this: FCSV.foreach(ARGV[0], :headers => true) do |row| table.insert(:call_date => row[0], :caller_Id => row[1], :phone_no=> row[2], :destination => row[3], :duration => row[4], :call_cost => row[5]) -- Posted via http://www.ruby-forum.com/.