From: Craig Demyanovich Date: 2009-03-01T23:16:42+09:00 Subject: Re: How to find the specific row of CSV file. --0016364ee5a2ea49dc04640f5dca Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On Sun, Mar 1, 2009 at 8:06 AM, Salil Gaikwad wrote: > thanx james & craig > > it works 4 me but is it right to use for a csv file which has more than > 5000 rows? I don't think that there's any intrinsic reason not to use CSV for a 5000 line file. However, if you're bulk-loading a database, I'd try to use your database's tools for that. In your case, though, you want to apply some custom logic to decide what to do. So we're playing w/ CSV. :-) > also > I use following method to read CSV file. > > @parsed_file=FasterCSV.read("#{RAILS_ROOT}/.....",:col_sep=>",", > :quote_char=>",", :force_quotes=>true) > @parsed_file.each_with_index do |row, index| > // more code here > > end > > My problem is that when there is a special characters in csv row-field > it gives me either an error or wrong value for ex. "\".63\"" for .63 > > what should i do so that it accept and hence read all the characters & > special characters so that i save it into the database(mysql) correctly. What strikes me as odd is that you have comma as both the :col_sep and the :quote_char. The FasterCSV defaults are comma for :col_sep and " for :quote_char. Can you give the whole row that contains the .63 value and that isn't working? If so, maybe we can come up with code that will parse it into the values that you want. Regards, Craig -- Craig Demyanovich Mutually Human Software http://mutuallyhuman.com --0016364ee5a2ea49dc04640f5dca--