Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Pandas read_csv无法正确解析行_Python_Pandas_Csv - Fatal编程技术网

Python Pandas read_csv无法正确解析行

Python Pandas read_csv无法正确解析行,python,pandas,csv,Python,Pandas,Csv,我在尝试读取csv文件并使用python 2.7使用pandas正确解析它时遇到问题 一些线路出现故障: 欧罗巴,2018-04-2026948,15,Destino,CRU-159617-JUN-2018,Origen,Productos incluidos,,“西班牙、法国、意大利、马耳他” 澳大利亚,2018-05-0139155,15,Destino,CRU-180907-2019年1月,Origen,Productos incluidos,,,“澳大利亚”,34048,“Nueva Z

我在尝试读取csv文件并使用python 2.7使用pandas正确解析它时遇到问题

一些线路出现故障:

欧罗巴,2018-04-2026948,15,Destino,CRU-159617-JUN-2018,Origen,Productos incluidos,,“西班牙、法国、意大利、马耳他”

澳大利亚,2018-05-0139155,15,Destino,CRU-180907-2019年1月,Origen,Productos incluidos,,,“澳大利亚”,34048,“Nueva Zelanda”

守则:

frame = pd.read_csv(filepath_or_buffer=raw_file)
-- 编辑:

我遇到的问题是,我将返回一个带有孔行的列

-- 编辑2:

问题是excel对某些行进行了酸性编辑,并在某些行的和和末尾添加了“现在它工作正常了。

pandas.Series.str和apply函数
输出:


您似乎没有使用分隔符。 试试这个:

pd.read_csv(filepath_or_buffer=raw_file, sep=r',')

你说失败是什么意思?你会得到什么错误?@AsavPatel我不会解析它。它将返回一个带孔行的列。你是否使用了参数sep=','?@Marco似乎一行比另一行有更多的列(检查最后一个元素)。即使在引号之间也会出现问题:“Espana、Francia、Italia、Malta”和“Nueva Zelanda”“我知道这一点,但我想告诉熊猫们不要理会其间的一切”
pd.read_csv(filepath_or_buffer=raw_file, sep=r',')