Skip to content
Advertisement

How to organize excel file by python?

I wrote a program to open an excel file and try to get 3 column in it. after running the program unfortunately It is not exactly what should it be. If I show you the pictures you will understand what I am talking about.

This is the original excel file:

enter image description here

After running the program the excel file is something like this:

enter image description here

in the above photo we have some lines which does not have any column. It is stupid. because if I click merging the data will come back! I don’t want to be like about. my purpose is something like below:

enter image description here

This is my code:

JavaScript

Advertisement

Answer

Interesting. This is arguably a bug in openpyxl. Because you deleted rows 1 and 3, each of which have their first 4 columns merged, you would expect them to become unmerged, but they don’t.

You can either explicitly delete the 2 groups of merged cells (before deleting the rows), or simply unmerge all merged cells.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement