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
Post a Comment