csv - Python Pandas read_csv skip rows but keep header -


i'm having trouble figuring out how skip n rows in csv file keep header 1 row.

what want iterate keep header first row. skiprows makes header first row after skipped rows. best way of doing this?

data = pd.read_csv('test.csv', sep='|', header=0, skiprows=10, nrows=10) 

you can pass list of row numbers skiprows instead of integer. reader ignore rows in list.

by giving function integer 10, you're skipping first 10 lines.

to keep first row 0 (as header) , skip row 10, write:

pd.read_csv('test.csv', sep='|', skiprows=range(1, 10)) 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -