How to remove the extra double quote?

后端 未结 5 1996
再見小時候
再見小時候 2021-01-26 02:37

In a malformed .csv file, there is a row of data with extra double quotes, e.g. the last line:

Name,Comment
\"Peter\",\"Nice singer\"
\"Paul\",\"Love \"folk\" so         


        
5条回答
  •  野性不改
    2021-01-26 03:29

    Unless you have no other choice, get the file regenerated with correct escaping. Any other approach is asking for trouble, because the insertion of unescaped quotes is lossy, and thus cannot be reliably reversed.

    If you can't get the file fixed from the source, then Tim Pietzcker's regex is better than nothing, but I strongly recommend that you have your script print all "fixed" lines and check them for errors manually.

提交回复
热议问题