[英]Rows are lost when reading this tab-separated file with pandas read_csv
我有一个具有以下格式的.text
文件,其中的字段(索引号,名称和消息)由\\t
分隔(制表符分隔):
712 ben Battle of the Books
713 james i used to be in TOM
714 tomy i was in BOB once
715 ben Tournaments of Minds
716 tommy Also the Lion in the upcoming school play
717 tommy Can you guess
718 tommy P
...
我用read_csv
将其读入数据帧:
chat = pd.read_csv("f.text", sep = "\t", header = None, usecols = [2])
但是数据帧只有9812
行,而普通文件有12428
行(仅21空行)。 这很奇怪。 你有什么主意吗? 谢谢。
我认为您需要添加参数quoting
:
import csv
chat = pd.read_csv("f.text",sep = "\t", header = None, usecols = [2], quoting=csv.QUOTE_NONE)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.