feat: expand CSV reader/writer with config, delimiters, and tests#41
Merged
feat: expand CSV reader/writer with config, delimiters, and tests#41
Conversation
- Add CsvConfig struct for customizable headers, delimiter, and flexibility - Add from_str_with_config() and from_reader_with_config() for custom parsing - Add to_string_with_config() for custom serialization - Support no-header mode (array of arrays) - Support custom delimiters (tab, pipe, semicolon, etc.) - Support flexible/ragged rows with extra column mapping - Union headers from all rows when serializing - Support writing array-of-arrays without headers - Add 45+ tests covering: basic CSV, no-header mode, TSV/pipe/semicolon delimiters, quoted fields (commas/quotes/newlines), type inference, empty fields, cross-format roundtrips (CSV↔JSON), large CSV (1000 rows), unicode headers/values, ragged rows (strict + flexible), union headers, null serialization, bool roundtrip, header order, whitespace handling, array-of-arrays output, and no-header roundtrip Fixes #11
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.
Summary
Closes #11 — CSV reader/writer.
Changes
New functionality:
CsvConfigstruct: Configurablehas_headers,delimiter, andflexibleoptionsfrom_str_with_config()/from_reader_with_config(): Parse CSV with custom settingsto_string_with_config(): Serialize with custom delimiter and header optionscolumn_N), short rows have missing keysNew tests (45+):
from_readerwith default and custom configAll checks pass:
cargo build,cargo test(246 tests),cargo fmt --check,cargo clippy -D warnings.