read_csv with missing/incomplete header or irregular number of columns

前端 未结 4 1864
小鲜肉
小鲜肉 2021-01-18 08:12

I have a file.csv with ~15k rows that looks like this

SAMPLE_TIME,          POS,        OFF,  HISTOGRAM
2015-07-15 16:41:56,  0-0-0-0-3,   1,           


        
4条回答
  •  不思量自难忘°
    2021-01-18 08:31

    Assuming your data is in a file called foo.csv, you could do the following. This was tested against Pandas 0.17

    df = pd.read_csv('foo.csv', names=['sample_time', 'pos', 'off', 'histogram', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17'], skiprows=1)
    

提交回复
热议问题