我想從包含不同列但不帶分隔符的csv文件創建數據框。看起來,列條目之間只有不同數量的空格。如何創建一個沒有分隔符的CSV格式的熊貓數據框(在Python中)
另外,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設置爲「無趣行數」 – MaxU