How to read file with space separated values in pa

2019-01-14 00:19发布

I try to read the file into pandas. The file has values separated by space, but with different number of spaces I tried:

pd.read_csv('file.csv', delimiter=' ')

but it doesn't work

2条回答
放荡不羁爱自由
2楼-- · 2019-01-14 01:01

add delim_whitespace=True argument, it's faster than regex.

查看更多
爷的心禁止访问
3楼-- · 2019-01-14 01:06

you can use regex as the delimiter:

pd.read_csv("whitespace.csv", header=None, delimiter=r"\s+")
查看更多
登录 后发表回答