I'm trying to read some information from an excel-file using the xlrd-module. This works fine most of the time, but when the script encounters any scandinavian letters the script stops. I've been reading several posts about unicode and encoding, but I must admit I'm not familiar with it.
The cell I'm reading contains text (string) and is being read as unicode (as normal with xlrd
). One example of a value that fails is Glørmestervej
and it is read by xlrd as u'Gl\xf8mestervej
. If I try to print the variable, the script stops. I've had most success by encoding the value with latin1
:
print cellValue.encode("latin1")
which gives the result Glormestervej
, but with a KeyError.
How do I get the variable to become a string with ø
instead of \xf8
? The reason is that I need to use it as an input to another service and it does not seem to work using unicode.
Regards, Torbjørn