fix: handle empty and headerless datasets in DBF export#660
Open
santhreal wants to merge 1 commit into
Open
Conversation
export_set inferred field types from `dataset[0]`, which raised IndexError on a headers-only dataset (no rows) and, because it never checked for headers, raised a raw TypeError on a headerless dataset. Default field types to character when there are no rows, and raise HeadersNeeded (dbf needs field names) instead of leaking a TypeError.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DBF
export_setinferred each field's type fromdataset[0]. On a headers-only dataset (columns defined, no rows) that raisedIndexError, and because the function never checked for headers, a headerless dataset raised a rawTypeError: 'NoneType' object is not iterablefromzip(dataset.headers, ...).Two changes: default field types to character when there are no rows (a headers-only dataset now exports to a valid dbf that round-trips), and raise
HeadersNeededwhen the dataset has no headers, since dbf fields must be named (matches theHeadersNeededpattern used elsewhere rather than leaking a TypeError).