Search code examples
pythonpandasdataframerows

Delete rows above headers in a CSV using Python Pandas


I need to clean up a files using Pandas. But the raw files we are using have a couple of rows above the column headers that I need to erase before getting to work. I do not find how to get rid of them.

I suppose this has to be done before generating the frame.

Can someone help?

Thanks in advance.

Sample CSV raw file


Solution

  • You can try using the skiprows parameter in read_csv() :

    pd.read_csv('filename.csv', skiprows=5)