dbfread icon indicating copy to clipboard operation
dbfread copied to clipboard

Fixed b'.' cannot be converted to a float error in parseN

Open janneyt opened this issue 4 years ago • 0 comments

I wrote this change because I was importing a .dbf file to Pandas. I was continually getting a set of errors of this format:

ValueError: could not convert string to float: b'.'

I traced it back to the parseN method. What I believe was happening was there were ',' entries with absolutely no digits somehow being flagged as floats. I added the length check to the exception handling to avoid this situation and now my document imports correctly. I have only tested with Python 3.x versions. I also added a test to test_field_parser.py to maintain this behavior.

I chose to convert to NaN and not None because NaN is a float value and because Pandas attempts to convert all missing data to NaN.

janneyt avatar Oct 30 '21 03:10 janneyt