-1

I am trying to open several files using open from gspread. However, I get a spreadsheet not found error when the files have characters in their names that have umlauts (i.e. Sprüngli). I haven't been able to find anything related to this in the gspread or Google Drive API docs. Is there a way to work around this without changing the names of the files?

Many thanks.

  • 2
    Hello, and welcome to [SO]! When I tried to [reproduce your problem](https://gist.github.com/pastor-robert/0e77d10639f1835c0ccc6bf244c5e932), it worked perfectly for me. Could you create and test a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) and add it to your question? – Robᵩ Feb 24 '22 at 15:47
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Feb 24 '22 at 22:23
  • Are you entering the umlaut characters into the names you are trying to open? Or are you trying to enter non-diacritical characters in their place (e.g., `Sprungli` for `Sprüngli`)? If the latter, these will never match. We don't currently have enough information to answer much beyond this. – Erik Tyler Feb 26 '22 at 00:57
  • @ErikTyler I am not switching the names. I will try to create a reproducible example. – Makif Nayman Mar 01 '22 at 10:37
  • So I did some further testing: I am running the gspread open command for all the values in a list. And it seems the name gets messed up while doing so, the umlaut somehow gets separated from the letter and they turn into two separate characters. – Makif Nayman Mar 01 '22 at 14:39

1 Answers1

0

So I finally figured out my solution. The umlauts were somehow getting separated from the letters as I was iterating through a list of the filenames and I solved it with unicodedata.normalize.

from unicodedata import name, normalize
[normalize('NFC', s) for s in filenames]