what is quickest way to read a file chunk by chunk in pandas: I am doing something like this which I found on stackoverflow as well . but how I will keep track of skiprow and skip footer if my file rows are for example like 1000 ?
# if the file contains 300 rows, this will read the middle 100
df = pd.read_excel('/path/excel.xlsx', skiprows=100, skip_footer=100)
You could use range
. Assuming you want to process chunks of 100 lines in in 1000 lines excel file:
total = 1000
chunksize = 100
for skip in range(0, total, chunksize):
df = pd.read_excel('/path/excel.xlsx', skiprows=skip, nrows=chunksize)
# process df
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With