Sunday, April 27, 2025

31 character limit

Making something for work, a nice simple situation of reading all xlsx files in a folder and moving the data to a tab in a single xlsx file. Easy peesy. 

30 mins later I run it the first time. It ran, but was giving me "Excel found errors, but can recover the data". Data all looked good, except every tab after the first was named "Recovered #". 

2hrs of work, with lots of long walks, and off the clock research, later, I discovered that the issue is the file names that I am trying to use for the tab names are longer than 31 characters, and the first 31 characters are the same.  OK, the first 39 characters are the same, and then there are 10 more at the end that match. These file names are insanely long. 

So I set up a simple replace to remove everything that is duplicate data in the names, and it all works! The issue was in excel, not my code. I went so far as to try writing the data to a csv, and then to the final excel file to see if there was some weird characters or formatting setting it off, before I wondered if there is a limit to the size of an Excel sheet name.

No comments:

Post a Comment

We can't do that here

I remember years ago looking over a book, Automate the Boring Stuff with Python, and thinking how this would be so useful at work. Half of m...