Python 在DataFrame中加载.txt文件,文本之间使用分隔线。
我有一个文本文件,其中包含如下文本:Python 在DataFrame中加载.txt文件,文本之间使用分隔线。,python,pandas,dataframe,text,separator,Python,Pandas,Dataframe,Text,Separator,我有一个文本文件,其中包含如下文本: -------------------------------- I hate apples and love oranges. He likes to ride bike. -------------------------------- -------------------------------- He is a man of honour. She loves to travel. -------------------------------
--------------------------------
I hate apples and love oranges.
He likes to ride bike.
--------------------------------
--------------------------------
He is a man of honour.
She loves to travel.
--------------------------------
我想在dataframe中加载这个txt文件,每一行只包含分隔符之间的内容。例如:
第1行应类似于:
我讨厌苹果,喜欢桔子。
他喜欢骑自行车
第2行应类似于:
他是个正直的人。
她喜欢旅行。看起来你需要对文本进行预处理 尝试: 输出:
Test
0 I hate apples and love oranges. He likes to ri...
1 He is a man of honour. She loves to travel.
你试了什么?
Test
0 I hate apples and love oranges. He likes to ri...
1 He is a man of honour. She loves to travel.