Jan-02-2024, 06:42 PM
(This post was last modified: Jan-02-2024, 06:42 PM by deanhystad.)
Pandas knows nothing about excel formatting, but you can add formatting when you write a dataframe to an excel file. This is done by making a custom xlsx writer. XlsxWriter is a package for making custom "writers" that can be passed to to_excel().
If you know what cells changed, you can use a package like Openpyxl to open the existing excel file and modify the data of the cells, leaving the formatting alone. Looking at your example I don't see where you are getting any benefit from using Pandas. Maybe you could open the spreadheet using openpyxl, make all the changes using regular python code, and write the modified spreadsheet.
I'm a bit confused about this:
If you know what cells changed, you can use a package like Openpyxl to open the existing excel file and modify the data of the cells, leaving the formatting alone. Looking at your example I don't see where you are getting any benefit from using Pandas. Maybe you could open the spreadheet using openpyxl, make all the changes using regular python code, and write the modified spreadsheet.
I'm a bit confused about this:
except Exception as e: print(e)This extra code only results in getting less information about errors that occur.
# End sys.exit()This just results in your program raising an exception and ending. Your program will end anyway because there are no instructions left to execute.