Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about optimizing cell merge #180

Open
winterfell2021 opened this issue Aug 2, 2022 · 2 comments
Open

Question about optimizing cell merge #180

winterfell2021 opened this issue Aug 2, 2022 · 2 comments

Comments

@winterfell2021
Copy link

Hi there, thanks for your great work! I got a large dataframe 30*10000 for example, and about 100 groups for each column to merge. Like

for i in range(30):
        column = n2a(i+1)
        for j in range(100000 // 100 - 1):
            worksheet.range(f"{column}{j*100 + 1}", f"{column}{(j+1)*100}").merge()

How can i speed up the merge function?

@kevmo314
Copy link
Collaborator

kevmo314 commented Aug 2, 2022

I suspect the validation step is slowing your code down: https://github.com/kz26/PyExcelerate/blob/dev/pyexcelerate/Worksheet.py#L166-L168

You can get around it by doing something like:

worksheet._merges.append(worksheet.range(...))

Probably the proper way to do this would be to add a validate=False argument, we'd welcome a pull request for that.

@winterfell2021
Copy link
Author

Thanks your kind, quick reply. Got 44.35159114399994 seconds without validation and 712.614892569 seconds as normal! Thats insane! A pr will be made afterwards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants