dbfread
dbfread copied to clipboard
struct.error: unpack requires a bytes object of length 32
I am trying to open a simple dbase III file and I am getting
File "C:/Users/user/Documents/Python/SAG/dbftest.py", line 4, in <module>
test = DBF('SystemRecord.dbf')
File "C:\Python36-32\lib\site-packages\dbfread\dbf.py", line 122, in __init__
self._read_field_headers(infile)
File "C:\Python36-32\lib\site-packages\dbfread\dbf.py", line 224, in _read_field_headers
field = DBFField.unpack(sep + infile.read(DBFField.size - 1))
File "C:\Python36-32\lib\site-packages\dbfread\struct_parser.py", line 36, in unpack
items = zip(self.names, self.struct.unpack(data))
struct.error: unpack requires a bytes object of length 32
Im assuming there is some field/index in my file that is larger/shorter than some maximum. Any ideas whats causing this?
It's been a while but I ran into the same issue today. It seems like it has to do with a field issue. I changed a char field in the DBF from length 1 to 2 and then everything worked fine.
I've run into this when I've had a file that ended too soon. The parser expects to read a while field but gets too few bytes.
I got this error when the file was zero bytes.
It could at least raise a well-defined Exception, so that we can handle it better.