Repository navigation
Handle empty stdin in streaming csvjson - #1402
Open
eggbiscuit wants to merge 1 commit into
Open
eggbiscuit wants to merge 1 commit into
eggbiscuit wants to merge 1 commit into
Conversation
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.
csvjson --stream --no-inference --snifflimit 0raisesStopIterationand exits 1 when stdin is empty. An upstream filter that selects zero records can therefore fail an otherwise valid NDJSON pipeline. The buffered--streampath already emits nothing and exits successfully for the same input.Reproduce on master at
43d09bf1f39382bc2d66c4f892c9814901179ff8:Give the header read an empty default so an exhausted input produces zero output records and exits 0. Regression coverage checks empty stdin and empty-file controls with and without
--no-header-row. Both stdin subtests fail withStopIterationbefore the runtime change and pass afterward.Validated locally on macOS arm64, Python 3.12.13, agate 1.14.2:
pytest --cov csvkit -q— 368 passed, 4 skipped, 35 subtests passed.flake8 . --exclude .venv,isort . --check-only, andgit diff --checkpass.check-manifest --no-build-isolationpasses.This touches the same header-reading line refactored by #1394. When combining the changes, retain the empty-input handling alongside that PR's first-record preservation.