使用python中的熊猫读取带有文本的制表符分隔文件

时间:2020-01-22 20:06:47

标签: 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 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)

0 个答案:

没有答案