Open perttikellomaki opened 2 years ago
I'm not sure if I have an answer for you but have you tried specifying the encoding?
If you know what encoding you have, you might be able to get it to work this way. The DBF()
constructor's optional second argument is for an encoding:
table = DBF('asset.dbf', 'UTF-8')
for record in table:
print(record)
table = DBF('asset.dbf', 'Latin-1')
for record in table:
print(record)
Another option is to set the char_decode_errors
handler. The argument defaults to 'strict'
when unspecified.
So this...
table = DBF('asset.dbf')
Is the same as...
table = DBF('asset.dbf', char_decode_errors='strict')
But you could relax this requirement by specifying a more forgiving error handler (see Python's Error Handlers docs for more options):
table = DBF('asset.dbf', char_decode_errors='replace')
You might settle on some combination of the two... defining an expected encoding and loosening the error handling behavior:
table = DBF('asset.dbf', 'Latin-1', char_decode_errors='replace')
for record in table:
print(record)
I'm trying to read a database produced by an ancient version of the ACDsee photo manager program (don't ask). When I try to read it simply as:
I get
ValueError: Unknown field type: '7'
. I followed the advice in another issue and created a field parser as:This produces the stack trace below. Googling for the error suggests that maybe the file is being read with the wrong encoding. Is there an easy way to try reading e.g. with UTF-8?