Python Pandas reads_csv skips first x and last y lines

I think I can skip something obvious here, but I'm new to python and pandas. I am reading a large text file and want to use only the lines in the range (61.75496). I can skip the first 60 lines with

keywords = pd.read_csv('keywords.list', sep='\t', skiprows=60) 

How can I only include lines between these values? Unfortunately, the userows parameter is missing.

Is there something like

 range(start, stop, start, stop)? 
+5
source share
2 answers

Perhaps you can use the nrows argument to indicate the number of lines to read.

From the documentation -

 nrows : int, default None Number of rows of file to read. Useful for reading pieces of large files 

The code -

 keywords = pd.read_csv('keywords.list', sep='\t', skiprows=60,nrows=75436) #Here 75436 is 75496 - 60 
+4
source

You can use the nrows parameter

 keywords = pd.read_csv('keywords.list', sep='\t', skiprows=60, nrows=(74596-60)) 
+1
source

All Articles