Python3: AttributeError: 'str' object has no attribute 'decode'
Hi,
I am trying out savReaderWriter on python3.3.0 and I've installed the py3k package that was in issue #8 (https://bitbucket.org/fomcl/savreaderwriter/get/py3k.zip) and I get this error while trying to write spss-file: AttributeError: 'str' object has no attribute 'decode' at savWriter.py, line 239 in writerow self._pyWriterow(record) and in line 261 in _pyWriteRow value = template % value.decode(encoding), when for example trying to run wiki's typical use example (at the end of Write Spss system files section).
Comments (3)
-
repo owner -
repo owner Hi, I just uploaded version 3.3.0, which is tested with Python 2.7, 3.3 and Pypy
-
repo owner - changed status to resolved
This was probably fixed in version 3.3.0, see e.g. https://bitbucket.org/fomcl/savreaderwriter/downloads/savReaderWriter-3.3.0-py33-none-any.whl
Note that input must be given in bytes (b' prefix)!
- Log in to comment
Hi,
Yes, the Py3k version is not quite ready yet. That applies in particular to SavWriter, where I stopped coding while messing with the writerow method. I think it is fairly easy to make a working version and I will see if I can (finally!) make some time for this week. String (Python 2) substitution (%s) is not possible with Python 3 bytes objects and I was struggling to find a nice and efficient way to deal with this. Efficiency is especially important for the writerow method, which may be called millions of times. Perhaps I should make two implementations, one for Python 2 and one for Python 3. I hate using "if sys.version_info[0] > 2" in the code too much though!
Regards, Albert-Jan
regards, Albert-Jan