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

Dealing with '\x00' in a numeric field #24

Closed
ripdog opened this issue Oct 9, 2017 · 1 comment
Closed

Dealing with '\x00' in a numeric field #24

ripdog opened this issue Oct 9, 2017 · 1 comment

Comments

@ripdog
Copy link

ripdog commented Oct 9, 2017

Hello, and thank you so much for the super useful library!

I'm trying to import data from a very old and buggy VFP application. The DB is so dirt it even has \x00 characters in a numeric row. This causes dbfread to try and interpret it as a float, which fails as such:

Traceback (most recent call last):
  File "C:\Python36-32\lib\site-packages\dbfread\field_parser.py", line 168, in parseN
    return int(data)
ValueError: invalid literal for int() with base 10: b'\x00'

During handling of the above exception, another exception occurred:

...

  File "C:\Python36-32\lib\site-packages\dbfread\field_parser.py", line 79, in parse
    return func(field, data)
  File "C:\Python36-32\lib\site-packages\dbfread\field_parser.py", line 174, in parseN
    return float(data.replace(b',', b'.'))
ValueError: could not convert string to float: b'\x00'

I'm not worried about trying to retrieve useful data from that row - it's empty anyway. The problem is I don't see a way to skip that row during parsing without monkey-patching dbfread. Can you please give any guidance on this matter?

I suppose worst case scenario, I could delete the row from the input file somehow without using dbfread... no idea how, though.

Many thanks!

Oh, my code is basically just iterating through the entire dbf. for row in dbf_file kinda thing.

@ripdog
Copy link
Author

ripdog commented Oct 9, 2017

Just discovered this: https://dbfread.readthedocs.io/en/latest/field_types.html#invalidvalue

Sorry for spamming your issue tracker, heh.

@ripdog ripdog closed this as completed Oct 9, 2017
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

1 participant