码迷,mamicode.com
首页 > 其他好文 > 详细

ParserError: Error tokenizing data. C error: Expected 1 fields in line 122, saw 2

时间:2018-05-16 13:09:11      阅读:1846      评论:0      收藏:0      [点我收藏+]

标签:pandas   报错   import   enc   sep   err   display   expected   file   

数据分析和挖掘实战第15章的一段读取.txt文件报错

import pandas as pd

inputfile = ‘data/meidi_jd.txt‘
outputfile = ‘data/meidi_jd_process_1.txt‘
data = pd.read_csv(inputfile,encoding = ‘utf-8‘,header =None)



File "pandas/_libs/parsers.pyx", line 965, in pandas._libs.parsers.TextReader._tokenize_rows

File "pandas/_libs/parsers.pyx", line 2208, in pandas._libs.parsers.raise_parser_error

ParserError: Error tokenizing data. C error: Expected 1 fields in line 122, saw

修改为:

import pandas as pd

inputfile = ‘data/meidi_jd.txt‘
outputfile = ‘data/meidi_jd_process_1.txt‘
data = pd.read_csv(inputfile,encoding = ‘utf-8‘,header =None,sep=‘\t‘)

或者:

import pandas as pd

inputfile = ‘data/meidi_jd.txt‘
outputfile = ‘data/meidi_jd_process_1.txt‘
data = pd.read_csv(inputfile,encoding = ‘utf-8‘,header =None,delimiter=‘\t‘)

  

ParserError: Error tokenizing data. C error: Expected 1 fields in line 122, saw 2

标签:pandas   报错   import   enc   sep   err   display   expected   file   

原文地址:https://www.cnblogs.com/lukes1973/p/9044842.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!