Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struct.error: unpack requires a bytes object of length 32 #28

Open
Crazzzme opened this issue Feb 13, 2018 · 4 comments
Open

struct.error: unpack requires a bytes object of length 32 #28

Crazzzme opened this issue Feb 13, 2018 · 4 comments

Comments

@Crazzzme
Copy link

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?

@SolariaIT
Copy link

SolariaIT commented May 18, 2018

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.

@olemb
Copy link
Owner

olemb commented Dec 21, 2020

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.

@jdbranham
Copy link

I got this error when the file was zero bytes.

@fccoelho
Copy link

It could at least raise a well-defined Exception, so that we can handle it better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants