在python中使用熊猫读取带文本的制表符分隔文件
我有一个包含大量文本数据的txt文件,在python中使用熊猫读取带文本的制表符分隔文件,python,python-3.x,pandas,Python,Python 3.x,Pandas,我有一个包含大量文本数据的txt文件,sep=”“不起作用,因为第二列都是字符串 数据结构: sentence_index sentence 1 The Rock is destined to be the 21st Century 's new `` Conan '' and that he 's going to make a splash even greater than Arnold Schwarzenegger , Jean-Claud Van Damme or Steven
sep=”“
不起作用,因为第二列都是字符串
数据结构:
sentence_index sentence
1 The Rock is destined to be the 21st Century 's new `` Conan '' and that he 's going to make a splash even greater than Arnold Schwarzenegger , Jean-Claud Van Damme or Steven Segal .
2 The gorgeously elaborate continuation of `` The Lord of the Rings '' trilogy is so huge that a column of words can not adequately describe co-writer\/director Peter Jackson 's expanded vision of J.R.R. Tolkien 's Middle-earth .
3 Effective but too-tepid biopic
我使用的代码是:
sentences = pd.read_csv("filename.txt", sep=" ",error_bad_lines=False)
你能分享一个数据的例子吗?请对所有与python相关的问题始终使用generic[python]标记。不管怎样,什么不起作用?“第二列都是字符串”是什么意思?您说分隔符是一个制表符,但您传递的是一个空格作为分隔符…您想要的
sep
是\t