Glad to help.
> Second, I started out the first tests using Ubuntu's packaged version:
> that's python-dbf-0.88.16-1
> <http://packages.ubuntu.com/search?keywords=python-dbf&searchon=names&suite=all§ion=all>,
> so far so good. Then I wanted to look at what pypi had to offer and
> downloaded version 0.90.002 <http://pypi.python.org/pypi/dbf> from
> there. Here things started to go wrong: all other things unchanged, the
> newer dbf chokes when reading out records with "high ascii" characters,
> whereas the older one does not give any error and decodes them correctly
> to unicode.
>
> The older, correctly working, version is installed with Ubuntu's package
> system and lies in some files under /usr/share/pyshared/dbf, on the
> other hand I tested the newer 0.90.002 by just extracting dbf.py from
> the zip file downloaded from pypi and putting it in the same directory
> of my script.
>
> Actual error from 0.90.002 is:
> File "/foo/bar/baz/dbf.py", line 1651, in retrieveCharacter
> return fielddef['class'](data)
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 3:
> ordinal not in range(128)
>
> Is it a regression in dbf.py or am I doing something wrong?
Using both versions do a
test_table = dbf.Table('/whatever/tablename')
print test_table
The newer version should say
Table: ...
Type: ...
Codepage: ascii (plain ol' ascii)
...
What does the older version say?
~Ethan~
Using both versions do a
test_table = dbf.Table('/whatever/tablename')
print test_tableThe newer version should say
Table: ...
Type: ...
Codepage: ascii (plain ol' ascii)
...What does the older version say?
Luca,
Can you send me the dbf file?
~Ethan~
Found the problem -- I'll have a new version released shortly.
~Ethan~
source = dbf.Table('zonas_cp850.dbf', read_only=True)print sourcesource.open()for record in source:
print record['zona'] + ':', record['nombre']
source.close()
Type: dBase III Plus
Codepage: ascii (plain ol' ascii)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa5 in position 7: ordinal not in range(128)
Type: dBase III Plus
Codepage: ascii (plain ol' ascii)
Exception AttributeError: "'NoneType' object has no attribute 'seek'" in <bound method _DbfRecord.__del__ of > ignored
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa5 in position 7: ordinal not in range(128)
dbf.DbfError: record data not correct -- first character should be a ' ' or a '*'.
def codepage(yo, cp=None):
def codepage(yo, cp='\x02'):
Codepage: cp850 (International MS-DOS)and everything looks good.
Codepage: cp850 (International MS-DOS)
Exception AttributeError: "'NoneType' object has no attribute 'seek'" in <bound method _DbfRecord.__del__ of > ignored
source = dbf.Table('zonas_cp850.dbf', read_only=True, codepage='cp850')
This will temporarily use cp850 for the encoding/decoding functions. To
Thanks again for the very good bug report!