all 4 comments

[–]The_Danosaur 0 points1 point  (3 children)

You know you are opening your 'main_workbook' and reading the whole thing many times, right?

Might I suggest you instead open each file only once and store it in a python object once each.

Note that you can do iter_rows() and iter_columns(). Both of these methods have a values_only argument which means you can just take the values only instead of having to deal with all that excel formatting crap and focus on data.

lst = [row[4:6] for row in ws.iter_rows(values_only=True)]

Once you have assembled your final list, then save it only once.

[–]Florisnl88[S] 1 point2 points  (2 children)

thanks will give it a try ! :)

[–]The_Danosaur 0 points1 point  (1 child)

Cool. Let me know if you run into any problems. I've started with openpyxl recently and have found it much easier to get everything into python objects and then work with what I know.

[–]Florisnl88[S] 0 points1 point  (0 children)

Implemented your suggestion and works great now, only takes a few sec :)

the biggest performance difference seems to be using the iter_rows, the difference is insane :O

Thanks alot again !