Python 3.6, dbfread 2.0.7 error handling DBF with 'cp1252' struct.error

525 views
Skip to first unread message

Aaron Weisberg

unread,
Aug 10, 2017, 2:42:11 PM8/10/17
to Python dBase
Hi everyone,

Ive been banging my head against a wall for two days and figured one of the pros could help me. I'm trying to take several .DBF from a proprietary program and turn the relate the data to .CSV with Python. However, some of the files are not cooperating with me and send me an error:

site-packages\dbfread\dbf.py", line 224, in _read_field_headers
field = DBFField.unpack(sep + infile.read(DBFField.size - 1))
"in unpack items = zip(self.names, self.struct.unpack(data)) struct.error: unpack requires a bytes object of length 32"


My code is simply:
table = DBF('AR.DBF', load = True)


Can someone who has experienced something like this help me?

Thank you.

Ethan Furman

unread,
Aug 10, 2017, 2:45:38 PM8/10/17
to python...@googlegroups.com
On 08/10/2017 10:10 AM, Aaron Weisberg wrote:

> Ive been banging my head against a wall for two days and figured one of the pros could help me. I'm trying to take several .DBF from a proprietary program and turn the relate the data to .CSV with Python. However, some of the files are not cooperating with me and send me an error:
>
> site-packages\dbfread\dbf.py", line 224, in _read_field_headers
> field = DBFField.unpack(sep + infile.read(DBFField.size - 1))
> "in unpack items = zip(self.names, self.struct.unpack(data)) struct.error: unpack requires a bytes object of length 32"
>
>
> My code is simply:
> table = DBF('AR.DBF', load = True)

I'm not sure which module/library you are using, but it's not this one (which can be found at
https://pypi.python.org/pypi/dbf).

If you want to try with the dbf library, I'm sure someone here can help with any questions.

--
~Ethan~
Reply all
Reply to author
Forward
0 new messages