ParseError“错误标记化数据。C错误:第49行中应为1个字段,saw 2”

2024-10-03 11:12:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我是新来的熊猫,我知道有一些类似的问题与我有关,但当我读到它们时,我的似乎有点不同

以下是我要转换为csv文件的文件:

...............
............... // lots of text here same below
pass = B50tE5t
MX-NY4-Secure = 1,2
MNJ-NY4 = 18
NY4-MNJ = 18
CNJ-NY4 = 13
NY4-CNJ = 13
 

我的示例代码是:

import pandas as pd
print("called")

read_file = pd.read_csv(r'conf/auth.cfg.example')
read_file.to_csv(r'conf/auth.cfg.csv', index=None)

但是我得到了错误pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 49, saw 2

错误指向这一行MX-NY4-Secure = 1,2

因此,这个MX-NY4-Secure有多个值(1和2)。其他人可能有3个,比如(5,3,4)。他们中的大多数人只有一(5)、(7)等

有什么帮助吗


Tags: 文件csvauthpandasreadconf错误cfg