在 CSV 中正确转义双引号 [英] Properly escape a double quote in CSV
问题描述
我的 CSV 中有这样一行:
I have a line like this in my CSV:
三星 U600 24"、10000003409"、1"、10000003427"
24
旁边的引号用于表示英寸,而该引号旁边的引号用于关闭该字段.我正在使用 fgetcsv
读取该行,但解析器出错并将值读取为:
Quote next to 24
is used to express inches, while the quote just next to that quote closes the field. I'm reading the line with fgetcsv
but the parser makes a mistake and reads the value as:
三星 U600 24",10000003409"
我尝试在英寸引号前加一个反斜杠,但后来我只在名称中加了一个反斜杠:
I tried putting a backslash before the inches quote, but then I just get a backslash in the name:
三星 U600 24"
有没有办法在 CSV 中正确地转义它,以便该值是 Samsung U600 24"
,或者我是否必须在处理器中对其进行正则表达式?
Is there a way to properly escape this in the CSV, so that the value would be Samsung U600 24"
, or do I have to regex it in the processor?
推荐答案
使用 2 个引号:
"Samsung U600 24"""
这篇关于在 CSV 中正确转义双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!