【发布时间】:2017-06-30 14:03:59
【问题描述】:
我正在尝试使用 Python 解析我的 csv 文件。每行有四个以逗号分隔的元素。每个元素都是一个字符串,但它也可以包含逗号。如果元素包含逗号,则该元素被双引号引起来。以下示例显示了带引号和不带引号的两种不同情况:
http://data.europa.eu/esco/skill/CTC_43028,"use data extraction, transformation and loading tools","ETL|extract, transform, load","<div>Integrate information from multiple applications, created and maintained by various organisations, into one consistent and transparent data structure.</div>"
http://data.europa.eu/esco/skill/SCG.TS.1.4.m.2,support company plan,follow industry guidelines|follow organisation's vision|monitor policy implementation|support company mission,<div>Act within one's work role to advance the goals and vision of the organisation.</div>
我想要的是把每一行分成四个元素。 我尝试过使用 Python 的拆分功能,但没有成功。我想我必须使用正则表达式,但我不熟悉它。 你能帮忙吗? 非常感谢。
【问题讨论】:
-
csv模块呢?它是为此量身定做的。删除正则表达式...