Dbf5('file.dbf') AssertionError assert terminator == b'\r
Whenever I try to load a .dbf file I am getting an error.
>>> Dbf5('myfile.dbf')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\TARGET\WinPython-64bit-3.3.5.9\python-3.3.5.amd64\lib\site-packages\simpledbf\simpledbf.py", line 557, in __init__
assert terminator == b'\r'
AssertionError
>>>
I am using
simpledbf-0.2.6.tar.gz
on
Python 3.3.5 (v3.3.5:62cf4e77f785, Mar 9 2014, 10:35:05) [MSC v.1600 64 bit (AMD64)] on win32
Thanks, Andre Mikulec
I'm having the same problem. Is there any plans on addressing this issue?
I too have this problem with a file edited with the DBF Explorer.
Any update on this?
I have discovered that this is caused by unsupported column types: Date/Time (Timestamp), and Memo by trial and error, i.e. removing columns and a little debuggin in simpledbf.py
My guess is that the assertion errors are a result of incorrect DBF file versions. There is a section in the README that explains which DBF versions are acceptable.
Have a look at the table entitled "Database file header" on the dbf Wikipedia page. The very last byte of the header should be 0x0D, which is is a carriage return. If that is not true, then you might have a different file version. For example in DBF version 7, the header has a much different length, so this code will not process it correctly.
You can check the DBF version info from the first byte of your file as follows:
f = open('my.dbf', 'rb')
f.read(1)
Convert this hex value into binary. As per the DBF7 description, bits 0-2 tell you about the version number. For example, I downloaded the file "Health Indicator Attributes" from the HRSA website. When I checked the first byte, I got '\x03', which converts to 0000 0011 in binary. The first three bits (on the far right, i.e. 011) are equivalent to 3, which according the DBF7 notes linked above indicates a DBF version 5 file.
I hope this helps. If you'd like, you can use this code as a template to create a DBF version 7 reader using the format link that I've provided. I only deal with older DBF versions, so I won't have any bandwidth to make updates to this project.
same issues, still no updates on this?
same issue, updates?
is there any alternative for this library? As I can see there is no support
same issues, still no updates on this?
Same issue!
File ~/.local/lib/python3.8/site-packages/simpledbf/simpledbf.py:557, in Dbf5.__init__(self, dbf, codec)
554 self.columns = [f[0] for f in self.fields[1:]]
556 terminator = self.f.read(1)
--> 557 assert terminator == b'\r'
559 # Make a format string for extracting the data. In version 5 DBF, all
560 # fields are some sort of structured string
Same problem here... Please any fix for this?
Same problem here... any fix for this?