【发布时间】:2017-06-17 12:50:14
【问题描述】:
我想从一个包含不同列但没有分隔符的 csv 文件创建一个数据框。似乎列条目之间的空格数量不同。
此外,csv 顶部的一些标题行包含自述文件信息,根本没有任何列。
我在使用 pd.read_csv() 时遇到问题
谢谢!
文件看起来像这样:
This is a header of the textfile.The header has no columns.
This is a header of the textfile.The header has no columns.
This is a header of the textfile.The header has no columns.
...
P-X1-6030-07-A01 368963
P-X1-6030-08-A01 368964
P-X1-6030-09-A01 368965
P-A-1-1011-14-G-01 368967
P-A-1-1014-01-G-05 368968
P-A-1-1017-02-D-01 368969
...
【问题讨论】:
-
pd.read_fwf(filename, header=None, skiprows=N),您必须将 N 设置为“无趣行”的数量
标签: python-3.x csv pandas