- changed status to resolved
IOError with umlauts in path to a file for sav.SavReader
Issue #35
open
Hi AJ,
I recognized (in the most recent version of savReaderWriter) that (at least for Python2 32bit on Windows) I get an IOError when trying to read a file with sav.SavReader whose path contains umlauts.
I (first) tried the following:
import savReaderWriter as sav
f = 'ümläut.SAV'
#f = unicode(f, encoding='utf8')
#f = f.encode('cp1252')
#f = f.encode('utf8')
data = sav.SavReader(f, returnHeader=True, rawMode=True,
ioUtf8=True, ioLocale='german')
Additionally, I tried to explicitly convert f
to unicode (second) as well as a subsequent conversion of f
to the codepage of my locale (third) or to utf8 (fourth), neither of which works.
The errors I get (in the same order) are:
C:\temp>python test.py
Traceback (most recent call last):
File "test.py", line 13, in <module>
ioUtf8=True, ioLocale='german')
File "C:\Users\RitschelG\AppData\Local\Continuum\32bit\Anaconda\lib\site-packages\savreaderwriter-433b5a51a64e25ba02615db797c4637a197ab61e-py2.7.egg\savReaderWriter\savReader.py", line 82, in __init__
ioUtf8, ioLocale)
File "C:\Users\RitschelG\AppData\Local\Continuum\32bit\Anaconda\lib\site-packages\savreaderwriter-433b5a51a64e25ba02615db797c4637a197ab61e-py2.7.egg\savReaderWriter\header.py", line 34, in __init__
refSavFileName)
File "C:\Users\RitschelG\AppData\Local\Continuum\32bit\Anaconda\lib\site-packages\savreaderwriter-433b5a51a64e25ba02615db797c4637a197ab61e-py2.7.egg\savReaderWriter\generic.py", line 196, in openSavFile
with open(savFileName, mode) as f:
IOError: [Errno 2] No such file or directory: 'C:\\temp\\\xc3\xbcml\xc3\xa4ut.SAV'
C:\temp>python test.py
Traceback (most recent call last):
File "test.py", line 13, in <module>
ioUtf8=True, ioLocale='german')
File "C:\Users\RitschelG\AppData\Local\Continuum\32bit\Anaconda\lib\site-packages\savreaderwriter-433b5a51a64e25ba02615db797c4637a197ab61e-py2.7.egg\savReaderWriter\savReader.py", line 82, in __init__
ioUtf8, ioLocale)
File "C:\Users\RitschelG\AppData\Local\Continuum\32bit\Anaconda\lib\site-packages\savreaderwriter-433b5a51a64e25ba02615db797c4637a197ab61e-py2.7.egg\savReaderWriter\header.py", line 34, in __init__
refSavFileName)
File "C:\Users\RitschelG\AppData\Local\Continuum\32bit\Anaconda\lib\site-packages\savreaderwriter-433b5a51a64e25ba02615db797c4637a197ab61e-py2.7.egg\savReaderWriter\generic.py", line 196, in openSavFile
with open(savFileName, mode) as f:
IOError: [Errno 2] No such file or directory: 'C:\\temp\\\xc3\xbcml\xc3\xa4ut.SAV'
C:\temp>python test.py
Traceback (most recent call last):
File "test.py", line 13, in <module>
ioUtf8=True, ioLocale='german')
File "C:\Users\RitschelG\AppData\Local\Continuum\32bit\Anaconda\lib\site-packages\savreaderwriter-433b5a51a64e25ba02615db797c4637a197ab61e-py2.7.egg\savReaderWriter\savReader.py", line 82, in __init__
ioUtf8, ioLocale)
File "C:\Users\RitschelG\AppData\Local\Continuum\32bit\Anaconda\lib\site-packages\savreaderwriter-433b5a51a64e25ba02615db797c4637a197ab61e-py2.7.egg\savReaderWriter\header.py", line 34, in __init__
refSavFileName)
File "C:\Users\RitschelG\AppData\Local\Continuum\32bit\Anaconda\lib\site-packages\savreaderwriter-433b5a51a64e25ba02615db797c4637a197ab61e-py2.7.egg\savReaderWriter\generic.py", line 213, in openSavFile
checkErrsWarns(msg, retcode)
File "C:\Users\RitschelG\AppData\Local\Continuum\32bit\Anaconda\lib\site-packages\savreaderwriter-433b5a51a64e25ba02615db797c4637a197ab61e-py2.7.egg\savReaderWriter\error.py", line 119, in checkErrsWarns
raise SPSSIOError(msg, retcode)
savReaderWriter.error.SPSSIOError: Problem opening file 'C:\\temp\\\xfcml\xe4ut.SAV' in mode u'rb' [SPSS_INVALID_FILE]
C:\temp>python test.py
Traceback (most recent call last):
File "test.py", line 13, in <module>
ioUtf8=True, ioLocale='german')
File "C:\Users\RitschelG\AppData\Local\Continuum\32bit\Anaconda\lib\site-packages\savreaderwriter-433b5a51a64e25ba02615db797c4637a197ab61e-py2.7.egg\savReaderWriter\savReader.py", line 82, in __init__
ioUtf8, ioLocale)
File "C:\Users\RitschelG\AppData\Local\Continuum\32bit\Anaconda\lib\site-packages\savreaderwriter-433b5a51a64e25ba02615db797c4637a197ab61e-py2.7.egg\savReaderWriter\header.py", line 34, in __init__
refSavFileName)
File "C:\Users\RitschelG\AppData\Local\Continuum\32bit\Anaconda\lib\site-packages\savreaderwriter-433b5a51a64e25ba02615db797c4637a197ab61e-py2.7.egg\savReaderWriter\generic.py", line 196, in openSavFile
with open(savFileName, mode) as f:
IOError: [Errno 2] No such file or directory: 'C:\\temp\\\xc3\xbcml\xc3\xa4ut.SAV'
Cheers Gerhard
Comments (2)
-
repo owner -
reporter - changed status to open
I checked again today and it seems this error is not resolved. I tried to open the file 'test.sav' from the directory 'C:\temp\a', where everything works and then the same file from the directory 'C:\temp\ä' (German umlaut 'a'), where it fails with the error
SPSSIOError: Problem opening file 'c:\\temp\\\xe4\\test.sav' in mode u'rb' [SPSS_INVALID_FILE]
- Log in to comment
Fixed issue #35 (hopefully), added unittests with filenames with non-ascii chars. Fixed typo in skipIf decorator
→ <<cset 9af476428110>>