如何在熊猫read_csv()中指定行定界符?

时间:2020-04-20 09:31:33

标签: python pandas

对于\n,我将使用与pandas.read_csv()不同的行定界符。有人知道怎么做吗?

read_csv()的文档中,没有发现任何相关信息,但是在to_csv()页面中,我找到了参数line_terminator

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

这里是一个例子:

文件:a.csv

hello,world:hell,worl:hel,wor:he,wo
a = pd.read_csv('a.csv', lineterminator=':')
print(a)

输出:

    hello world
  0  hell  worl
  1   hel   wor
  2    he    wo