Why does splitting on commas corrupt quoted annotation notes?

The CSV reader interprets delimiter and quoting rules, allowing a delimiter inside a quoted field.

Python example and interpretation

One annotation describes a scene as wet, dark. A literal split invents an extra column. Match delimiter and quote settings to the producer's dialect.

import csv
next(csv.reader(['17,"wet, dark",ok']))

Result ['17', 'wet, dark', 'ok']

中文

为什么包含逗号的标注说明不能直接按逗号拆分?

CSV reader 按字段分隔符和引号规则读取记录,带引号字段内部可包含分隔符。

Python 算例与适用条件

一行将“wet, dark”作为一条描述。按逗号盲拆会多生成一列;生产者若使用不同方言,还要同步配置分隔符与引号。

import csv
next(csv.reader(['17,"wet, dark",ok']))

结果 ['17', 'wet, dark', 'ok']

References / 参考来源

Keep reading / 继续阅读