Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas read_excel: only read first few lines

Tags:

pandas

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).

This doesn't work but illustrates the goal (example reading 10 data rows):

workbook_dataframe = pd.read_excel(workbook_filename, nrows = 10)

This is my current workaround:

workbook_dataframe = pd.read_excel(workbook_filename).head(10)

Problem with the workaround is it has to read the entire excel file before taking the head. I've also tried experimenting with skiprows and skip_footer, giving it negative numbers which just produces errors.

like image 311
Vlad Avatar asked Nov 07 '22 21:11

Vlad


1 Answers

This isn't currently supported although looking at the code it doesn't look like it should be too hard. You can open an issue on the Github project page at https://github.com/pandas-dev/pandas/issues.

like image 140
maxymoo Avatar answered Nov 24 '22 19:11

maxymoo