:
require 'csv'
CSV.parse(DATA.read,:col_sep=>';',:headers=>true,
) do |row|
p row
end
, : Illegal quoting in line 3. (CSV::MalformedCSVError)
, , :skip_lines:
require 'csv'
CSV.parse(DATA.read,:col_sep=>';',:headers=>true,
:skip_lines=> /a " in the text/
) do |row|
p row
end
__END__
a;b;c;d
1;2;3;4
here we have an error because there is a " in the text;
1;2;3;4
"1";"2";3;4
:
#<CSV::Row "a":"1" "b":"2" "c":"3" "d":"4">
#<CSV::Row "a":"1" "b":"2" "c":"3" "d":"4">
#<CSV::Row "a":"1" "b":"2" "c":"3" "d":"4">
CSV ( "), qoute :
require 'csv'
CSV.parse(DATA.read,:col_sep=>';',:headers=>true,
quote_char: '§'
) do |row|
p row
end
, , (. ):
#<CSV::Row "a":"1" "b":"2" "c":"3" "d":"4">
#<CSV::Row "a":"here we have an error because there is a \" in the text" "b":nil "c":nil "d":nil>
#<CSV::Row "a":"1" "b":"2" "c":"3" "d":"4">
#<CSV::Row "a":"\"1\"" "b":"\"2\"" "c":"3" "d":"4">