dbfpy icon indicating copy to clipboard operation
dbfpy copied to clipboard

Error with dbase dbf files

Open paridin opened this issue 10 years ago • 1 comments

Hi Steelwing,

i feel confused with this part of code in file dbfpy/header.py, line 160

             if pos != field.start:
                raise ValueError(
                    'dbf fields definition is corrupt, '
                    'fields start does not match.'
                )

using a dbase file, it returns another number, so i reviewed your dbf files included in your test folder, i saw the dbf is of Visual Foxpro right?.

I tried my own test with a dbase file, and the field.start is set with 1271005187, so in the if statement it return me a raise statement, if commented the statement does not retrieve the values of the fields because i guess the position is important to retrieve the right value, for that reason only commented the raise statement and i set the field.start with the pos variable and it works.

>>> string=b'NORMAL\x00\x00\x00\x00\x00N\x03\x00\xc2K\x04\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>>> struct.unpack('< 11s c I 3B I B', string[:24])
(b'NORMAL\x00\x00\x00\x00\x00', b'N', 1271005187, 4, 0, 0, 256, 0)

Well the way to solve my problem is it:

            if pos != field.start:
                field.start = pos
                """
                raise ValueError(
                    'dbf fields definition is corrupt, '
                    'fields start does not match.'
                )
                """

i tested with the table.dbf and it works, so maybe you can include this change, to make compatible with dbf from dbase III and Visual Foxpro because the variable pos did set fine.

paridin avatar Jan 29 '15 18:01 paridin

Thanks, I look for the dBase file structure, and it look like different to FoxPro, if need to support dBase, may be need more works.

steelywing avatar Feb 04 '15 05:02 steelywing