Skip to content

feat: unnest transform - #78

Merged
close2 merged 3 commits into
masterfrom
CL/v8
Mar 19, 2026
Merged

feat: unnest transform#78
close2 merged 3 commits into
masterfrom
CL/v8

Conversation

@close2

Copy link
Copy Markdown
Owner

fixes#77

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CsvDecoder and CsvEncoder to be StreamTransformerBase implementations (row-per-event) while keeping batch convert(...)-style APIs.
  • Introduces Csv as the primary API (with deprecated CsvCodec typedef) and adds asCodec() as a dart:convertCodec adapter 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
FileDescription
lib/src/csv_decoder.dartRefactors decoding to emit one row per stream event while preserving batch decode via convert().
lib/src/csv_encoder.dartRefactors encoding to accept one row per stream event and preserves batch encode via convert().
lib/src/csv_codec.dartReplaces CsvCodec class with Csv, adds encode/decode helpers and introduces asCodec() adapter.
lib/csv.dartUpdates top-level csv/excel instances to use Csv.
test/csv_test.dartUpdates chunked conversion tests to assert flat row emission and new encoder input types.
test/small_chunk_test.dartUpdates expectations to match row-per-event decoding (no manual flattening).
test/parse_headers_test.dartUpdates to construct Csv(parseHeaders: true) and keeps header parsing behavior tests.
test/split_escape_test.dartUpdates chunked decoding sink setup to collect row events directly.
test/split_crlf_test.dartSame as above for CRLF chunking scenarios.
test/multi_char_delim_test.dartSame as above for multi-character delimiter chunking scenarios.
example/csv_fuse_example.dartUpdates .fuse() example to use csv.asCodec() as the supported path.
benchmark/benchmark_csv.dartUpdates benchmark streams to use per-row events and uses asCodec() for fuse benchmarking.
README.mdDocuments v8 upgrade, stream row-per-event behavior, and explains the Codec/asCodec() tradeoff.
CHANGELOG.mdAdds v8.0.0 entry describing the fix and breaking changes.
pubspec.yamlBumps version to 8.0.0 and updates package description.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadlib/src/csv_codec.dart
Comment threadlib/src/csv_codec.dart
Comment threadREADME.md Outdated
@close2
close2 requested a review from CopilotMarch 18, 2026 20:31

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restructures the CSV API to fix issue #77 (“extra layer of []” when using stream.transform(csv.decoder).toList()) by making the decoder/encoder true stream transformers that emit one row per stream event, while preserving a dart:convertCodec pathway via asCodec().

Changes:

  • Refactors CsvDecoder/CsvEncoder into StreamTransformerBase implementations (one row per event) to eliminate List<List<List<dynamic>>> nesting in stream usage.
  • Renames CsvCodecCsv (with deprecated CsvCodec typedef) and adds Csv.asCodec() to support Codec.fuse() and other dart:convert-only APIs.
  • Updates docs, examples, benchmarks, and tests to the new stream semantics and asCodec() usage; adds new asCodec() test coverage.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
FileDescription
lib/src/csv_decoder.dartEmits one decoded row per stream event; keeps batch convert() returning all rows.
lib/src/csv_encoder.dartEmits one encoded row fragment per stream event; keeps batch convert() for full CSV output.
lib/src/csv_codec.dartIntroduces Csv as primary API, adds asCodec() adapter, deprecates CsvCodec name.
lib/csv.dartUpdates exported defaults (csv, excel) to be Csv instances.
README.mdDocuments v8 upgrade, stream behavior, and asCodec() rationale/usage.
CHANGELOG.mdAdds v8.0.0 breaking changes and notes the stream nesting fix.
pubspec.yamlBumps version to 8.0.0 and updates package description.
example/csv_fuse_example.dartUpdates fuse example to use csv.asCodec().
benchmark/benchmark_csv.dartUpdates benchmark to stream per-row events and use asCodec() for fuse benchmark.
test/csv_test.dartUpdates chunked conversion tests to new flat (row-per-event) stream behavior.
test/small_chunk_test.dartRemoves now-unnecessary unnesting in expectations for stream decoding.
test/parse_headers_test.dartMigrates to Csv(parseHeaders: true) API.
test/split_escape_test.dartUpdates chunked sink usage for per-row emission.
test/split_crlf_test.dartUpdates chunked sink usage for per-row emission.
test/multi_char_delim_test.dartUpdates chunked sink usage for per-row emission.
test/as_codec_test.dartAdds comprehensive tests for asCodec() behavior and batching controls.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadtest/csv_test.dart Outdated
@close2
close2 merged commit 117f64d into masterMar 19, 2026
6 checks passed
@close2
close2 deleted the CL/v8 branch March 19, 2026 07:42
Sign up for freeto 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.

openRead returns one more layer of []

2 participants

@close2