问题描述
根据Gran的说法,该公司没有计划将所有生产转移到俄罗斯,尽管那是该公司增长的地方。@中性
上面是文本,我想用@分隔它,以便产生两列
data = pd.read_csv(r'F:\Sentences_50Agree.csv',sep='@',header=None)
我尝试了上面的方法,但是没有用。它仅显示1列,总文字包括@neutral
解决方法
import pandas as pd
from io import StringIO
s = 'According to Gran,the company has no plans to move all production to Russia,although that is where the company is growing .@neutral'
print( pd.read_csv(StringIO(s),sep='@',header=None) )
打印:
0 1
0 According to Gran,the company has no plans to... neutral
或带有文件:
print( pd.read_csv('file.txt',header=None) )