Skip to content

Gracefully handle NULL numeric, date fields #16

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

Merged
merged 1 commit into from
Jan 9, 2015

Conversation

riggsd
Copy link

@riggsd riggsd commented Dec 3, 2014

Though the DBase spec doesn't allow NULL values, QGIS allows one to write/edit a Shapefile with specially-encoded NULL values. It does this by writing full-width '*' characters for numeric types, and '0' characters for date types.

Pyshp blows up with a ValueError when parsing these NULL values. This patch gracefully handles these specially-encoded NULLs, and hands back None as a value, which is much more Pythonic than casting incorrectly to 0 or [0, 0, 0] respectively.

Also attached is a simple example Shapefile created by QGIS with NULL values.

screenshot 2014-12-03 17 59 32

GeospatialPython added a commit that referenced this pull request Jan 9, 2015
Gracefully handle NULL numeric, date fields
@GeospatialPython GeospatialPython merged commit 0e5de22 into GeospatialPython:master Jan 9, 2015
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

Successfully merging this pull request may close these issues.

2 participants