CSV parser fails with mixed quoting and non-standard row_sep

未關閉
#107 9 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
45/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
ruby
領域
data

研究方向

首先使用 row_sep: "|\n" 透過 CSV.generate 和 CSV.parse 重現該範例,然後將加引號和未加引號的列與成功的案例進行比較。追蹤剖析器如何處理列分隔符號和欄位引號;完成的條件是混合引號輸入能在不出現 CSV::MalformedCSVError 的情況下完成剖析,同時現有替代方案仍然有效。

由索引模型根據 Issue 內容生成。

描述

opts = {row_sep: "|\n", col_sep: ","}
CSV.parse(CSV.generate(opts) { |csv|
  csv << ["yes, it's true"];
  csv << [ "CSV is broken"];
  csv << ["uhoh!"]; }, opts)

In the example above, the parser will raise a CSV::MalformedCSVError (Unquoted fields do not allow new line <"\n"> in line 2.) error.

It will succeed if any of the following are done:

  1. pass force_quotes: true to generate
  2. add a comma in each row
  3. remove the comma from the first row
  4. use row_sep: "\n"

Therefore, the problem seems to be that a non-standard row_sep + lines with a field being quoted in one row and unquoted in the next.

主要語言
Ruby
星號
220
分支
139
平均合併
1 天 1 小時
30 天內合併 PR
2

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

ruby/csv 的其他 Issue

查看 ruby/csv 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。