我有一个.text
文件,格式如下:
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
...
索引号,姓名和消息由\t
分隔。我使用read_csv
来读取文件并将其存储为数据框:
chat = pd.read_csv("f.text", sep = "\t", header = None, usecols = [2])
但是数据框只有9812
行,而普通文件有超过12428
行(只有21行)。这很奇怪。你有什么主意吗?感谢。
答案 0 :(得分:6)
我认为您需要添加参数quoting
:
import csv
chat = pd.read_csv("f.text",sep = "\t", header = None, usecols = [2], quoting=csv.QUOTE_NONE)