Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #77 by changing the library’s stream transformation model so CSV decoding/encoding streams emit one row per event, eliminating the extra List<List<...>> nesting that appeared when using Stream.transform(...).toList() after upgrading to v7.
Changes:
- Refactors
CsvDecoderandCsvEncoderto beStreamTransformerBaseimplementations (row-per-event) while keeping batchconvert(...)-style APIs. - Introduces
Csvas the primary API (with deprecatedCsvCodectypedef) and addsasCodec()as adart:convertCodecadapter for.fuse()use cases. - Updates tests, examples, benchmarks, docs, changelog, and bumps package version to
8.0.0.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
lib/src/csv_decoder.dart |
Refactors decoding to emit one row per stream event while preserving batch decode via convert(). |
lib/src/csv_encoder.dart |
Refactors encoding to accept one row per stream event and preserves batch encode via convert(). |
lib/src/csv_codec.dart |
Replaces CsvCodec class with Csv, adds encode/decode helpers and introduces asCodec() adapter. |
lib/csv.dart |
Updates top-level csv/excel instances to use Csv. |
test/csv_test.dart |
Updates chunked conversion tests to assert flat row emission and new encoder input types. |
test/small_chunk_test.dart |
Updates expectations to match row-per-event decoding (no manual flattening). |
test/parse_headers_test.dart |
Updates to construct Csv(parseHeaders: true) and keeps header parsing behavior tests. |
test/split_escape_test.dart |
Updates chunked decoding sink setup to collect row events directly. |
test/split_crlf_test.dart |
Same as above for CRLF chunking scenarios. |
test/multi_char_delim_test.dart |
Same as above for multi-character delimiter chunking scenarios. |
example/csv_fuse_example.dart |
Updates .fuse() example to use csv.asCodec() as the supported path. |
benchmark/benchmark_csv.dart |
Updates benchmark streams to use per-row events and uses asCodec() for fuse benchmarking. |
README.md |
Documents v8 upgrade, stream row-per-event behavior, and explains the Codec/asCodec() tradeoff. |
CHANGELOG.md |
Adds v8.0.0 entry describing the fix and breaking changes. |
pubspec.yaml |
Bumps version to 8.0.0 and updates package description. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+176
to
+179
| Sink<String> startChunkedConversion(Sink<List<List<dynamic>>> sink) { | ||
| // Wrap the batch sink so individual rows are collected into batches. | ||
| return _decoder.startChunkedConversion(_BatchingSink(sink)); | ||
| } |
Comment on lines
+138
to
+142
| /// // Fuse with another codec | ||
| /// final fused = csv.asCodec().decoder.fuse(someConverter); | ||
| /// ``` | ||
| Codec<List<List<dynamic>>, String> asCodec() => _CsvCodecAdapter(this); | ||
| } |
| - `CsvCodec` has been renamed to `Csv`. A deprecated `CsvCodec` typedef is | ||
| available for migration. | ||
| - `Csv` no longer extends `dart:convert`'s `Codec` class. If you need a `Codec` | ||
| (e.g., for `.fuse()`), use [`asCodec()`](#the-codec-problem--ascodec). |
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.
fixes #77