2

I have a csv that looks like this:

s,k,i,p   # 0. N rows to skip
H,E,A,D   # 1. header names
n,o,n,e   # 2. N more rows to skip
1,2,3,4   # 3. Data
6,7,8,9   # 4. ...
...       # 5. ...

Can I read this data in with a single call to pandas.read_csv? I'm having trouble because I can't seem to skip rows until the header then skip more rows until the data

1 Answer 1

3

you can pass a list of rows to skip to skiprows like so:

In [2]:pd.read_csv('the_file.csv', skiprows=[0,2])
Out[2]:
   H  E  A  D
0  1  2  3  4
1  6  7  8  9
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.