Pandas read_excel: only read first few lines #16645
Code Sample, a copy-pastable example if possible
workbook_dataframe = pd.read_excel(workbook_filename, nrows = 10)
Using pandas read_excel on about 100 excel files - some are large - I want to read the first few lines of each (header and first few rows of data).
The above doesn't work but illustrates the goal (example reading 10 data rows).
You can add one line in your code below where you are reading your file. For example, if you want to read first 10 rows of the file then you can do this.
workbook_dataframe = pd.read_excel(workbook_filename)
or even you can simply do this
so that your data frame now contains only first 10 rows.
To get nrows without reading the entire worksheet: