olemb / dbfread

Read DBF Files with Python
MIT License
224 stars 91 forks source link

Error parsing dates #46

Open fccoelho opened 4 years ago

fccoelho commented 4 years ago

While opening a dbf I got this error:

ValueError: invalid date b'24/01/20' 

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/dbfread/field_parser.py in parseD(self, field, data)
     91         try:
---> 92             return datetime.date(int(data[:4]), int(data[4:6]), int(data[6:8]))
     93         except ValueError:

ValueError: invalid literal for int() with base 10: b'24/0'

the parser is apparently spliting the date in the wrong positions.

olemb commented 3 years ago

Yes, it's expecting YYYYMMDD but getting something with slashes.

Could you run it again with DBF(filename, raw=True) and tell me what the whole date looks like?