Hello,
I am getting error :-
#<CSV::MalformedCSVError: Unclosed quoted field on line 1892.>.
I have following code :-
--------------------------------------------------
@parsed_file
CSV.open("#{RAILS_ROOT}/private/sales_report_files/#{@file_folder}/#{@sub_file_folder}/#{@file_name.filename}",''r'',:col_sep
=>?\t)
@parsed_file.each_with_index do |row, index| # getting error on this
line
// some code
end
--------------------------------------------------
I have tried to escape row no.-1892 by using
''@parsed_file.shift'', but
it didn''t work.
Please suggest, so I can skip the corrupted row.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Unclosed quoted field on line means the line contans odd number of " or '' tom On Aug 3, 2011, at 16:45 , Gagan Shah wrote:> Hello, > I am getting error :- > #<CSV::MalformedCSVError: Unclosed quoted field on line 1892.>. > > I have following code :- > > -------------------------------------------------- > > @parsed_file > CSV.open("#{RAILS_ROOT}/private/sales_report_files/#{@file_folder}/#{@sub_file_folder}/#{@file_name.filename}",''r'',:col_sep > =>?\t) > > @parsed_file.each_with_index do |row, index| # getting error on this > line > > // some code > > end > > > -------------------------------------------------- > > I have tried to escape row no.-1892 by using ''@parsed_file.shift'', but > it didn''t work. > Please suggest, so I can skip the corrupted row. > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.-- ==============================================================================Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz ============================================================================== -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Gagan Shah wrote in post #1014733:> I am getting error :- > #<CSV::MalformedCSVError: Unclosed quoted field on line 1892.>. > > @parsed_file >CSV.open("#{RAILS_ROOT}/private/sales_report_files/#{@file_folder}/#{@sub_file_folder}/#{@file_name.filename}",''r'',:col_sep> =>?\t)I see that you''re input file is tab separated, but you have not mentioned how strings are delimited in your file.> I have tried to escape row no.-1892 by using ''@parsed_file.shift'', but > it didn''t work. > Please suggest, so I can skip the corrupted row.Take note that some people (and unfortunately some frameworks) incorrectly attempt to escape quotes using the backslash character (\"). The proper way to delimit strings in CSV files is to surround them with double quotes (") where strings containing double quote characters should escape them using two consecutive double quotes. Example: This is WRONG: "A string containing a double quote \" character", "Another string",23 This is correct: "A string containing a double quote "" character", "Another string",23 See http://tools.ietf.org/html/rfc4180 for more information. Section 2.7 explains the above. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.