openpyxl readonly use_iterators

Viewed 2298

I have some huge Excel files, but I'm stymied with even a "modest" one (50 Mbytes). I do need to skip over the first two rows, but I don't think that's the slowdown. Can you think of something else?

wb = load_workbook(MyFile,read_only=True)
ws = wb.active

NDepth = ws.max_row-2
NTime = ws.max_column -1

Local_Depth = np.zeros((NDepth,))
Local_Temp = np.zeros((NDepth,NTime))

iterlist = islice(ws.iter_rows(),2,None)

start = time.time()

i=0
for row in iterlist:
    Local_Depth[i] = row[0].value 
    j=0
    for col in row[1:]:
        Local_Temp[i,j] = col.value
        j += 1
    i += 1

print "Done", time.time()-start

It's taking me well over 7 minutes to load the file on a M4700 Dell Precision. About 8000 rows and 800 columns. Surely there must be something wrong? Could there be some other tweaks somewhere that I should be making in my Python 2.7 set-up?

Thank, John

3 Answers
Related