LoginSignup
3
3

More than 5 years have passed since last update.

標準ライブラリ csv で読むCSV に「\"」 が紛れ込んでるとエラーになる

Last updated at Posted at 2015-06-02

参考:標準ライブラリ csv に Missing or stray quote in line *** とか言われたら
http://qiita.com/yuya_takeyama/items/8f01c6c17103c5b2cb7e

1行ごとに文字を置換して対処。

open(path, open_mode, { :undef => :replace, :invalid => :replace } ) do |f|
  f.each_line.with_index do |line, j|
    line.gsub!('\"','""')
    CSV.parse(line) do |row|
      ...
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3