How do I read only a specific column and a specific row from a .csv file in Python?

Viewed 65

I have a csv file that has arrays in two columns and I would like to read those for a specific row. How do I do that?

So far, I have:

pd.read_csv('file_name.csv', usecols= [23], nrows=3)

But this reads every row below what is skipped and I don't want that.

Thank you!

1 Answers

If you now the row number you want to read you can use the skiprows argument and then get a single row with nrows=1 argument.

pd.read_csv('file_name.csv', usecols=[23], nrows=1, skiprows=3)

I hope I was useful :)

Related