Skip to content

feat: read the input with the dsv-parser library - #3

Merged
terwey merged 6 commits into
masterfrom
feat/dsv-parser
Nov 16, 2026
Merged

terwey merged 6 commits into
masterfrom
feat/dsv-parser

Conversation

@gastova-agent

@gastova-agent gastova-agent commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What this is

csv2sqlite reads its input with dsv-parser v0.1.0, the parser of this repository moved into a library. The parser package keeps the writing: the header, the rows, the part files and the merge.

Commit What it does
1bfc145 Reads the input with the library's Reader; removes the cutter, the splitters and their tests, which live in the library.
1a8005c, 4b7cb83 Pseudo-versions of the library used while it had no release.
7281e71 Requires v0.1.0 and writes one expected database again.
4379324 Removes the flags --chunk-size and --channel-capacity and the report fields that printed them.
68883a7 Names dsv-parser in the description and generates README.md again; the markdown target works with pandoc 3.

Without the generated README.md: 4,097 lines go, 218 come.

What changes for a user

  • --chunk-size and --channel-capacity are removed; passing one is an unknown-flag error. The reader hands records to its workers in batches of its own size, so neither had anything left to set.
  • The performance report loses the fields that printed them: the columns chunksize, channel-capacity and capacity of --csv-report (13 columns, were 16), and Performance.Chunksize, Performance.Capacity and Params.ChannelCapacity of the JSON report.
  • --threads still keeps one thread for the merge.
  • With --rowid a row is split as it is without it; the row id is no longer part of the line that is split.

What changes in the output

The library release holds three fixes to how files are read, and one behaviour that shows in a test of this repository:

  • A quoted field that holds a delimiter and then a line break is one record. It was cut at the line break when the delimiters before it added up to the header's count.
  • With the enclosure left to detection, a column of one repeated character (000) no longer hides the enclosure of a later column.
  • With the enclosure left to detection, a file whose only enclosed values are empty ("") is read with its enclosure: those fields are empty, they were the two characters "".
  • A backslash before an enclosure inside an enclosed value is read as an escape without --php. Three values of tests/csvSample.512034.11822895.csv change from 1\" ... to 1" .... Its expected database is written again in 7281e71; no other field of its 999 rows changes.

Measured

A 32 GB file with 10,380,652 rows on an Apple M2 Max, 12 threads, delimiter and enclosure set with -d PIPE -e QUOTATION_MARK:

Wall Peak memory
This branch at 4b7cb83, to SQLite 53.6 s 0.41 GB
This branch at 4b7cb83, --drop (parse only) 9.1 s 0.04 GB
Release build v0.23.1-rc, to SQLite 52.7 s 7.6 GB

The write to SQLite takes the same time; the parser is no longer what holds the memory.

Tested

  • go vet and go test pass for every package of the module.
  • go build ./cmd/csv2sqlite builds from a clean module cache with the released library; go.mod holds no local replace.
  • README.md is the output of make markdown with asciidoctor 2.0.23 and pandoc 3.1.11; its markup differs from the committed one because that was written by an older pandoc.

The reader of github.com/terwey/dsv-parser cuts the input into records
and splits them; it is this parser, moved into a library. The parser
package keeps the writing: the header, the rows, the parts and the merge.
Its split tests live in the library.

A worker of the reader writes its records to one part after another, as
a parser routine did. --threads still keeps one thread for the merge.
--chunk-size and --channel-capacity no longer change anything: the
reader hands records to its workers in batches of its own size.

With --rowid a row is split as it is without it; the row id is no longer
part of the line that is split.

go.mod is not part of this commit: the library has no release that holds
the options this needs.

Signed-off-by: Claude Fable 5.2 <agent@terwey.me>
A pseudo-version until the library has a release.

Signed-off-by: Claude Fable 5.2 <agent@terwey.me>
Signed-off-by: Claude Fable 5.2 <agent@terwey.me>
v0.1.0 is the first release of the library. It holds the options this
needs, so the pseudo-version goes.

The release reads a backslash before an enclosure inside an enclosed
value as an escape without --php: three values of
tests/csvSample.512034.11822895.csv change from `1\" ...` to `1" ...`.
The expected database of that sample is written again; no other field
of its 999 rows changes.

Signed-off-by: Claude Fable 5.2 <agent@terwey.me>
The reader hands records to its workers in batches of its own size, so
neither flag changed anything.

The flags --chunk-size and --channel-capacity are gone, and with them
the report fields that printed them: the columns chunksize,
channel-capacity and capacity of --csv-report, and Chunksize, Capacity
and Params.ChannelCapacity of the JSON report.

Signed-off-by: Claude Fable 5.2 <agent@terwey.me>
The description says the input is read with dsv-parser. README.md is
generated again from docs/readme.adoc: it no longer lists the removed
flags --chunk-size and --channel-capacity, and --start shows its
default of 1.

pandoc 3 has no --atx-headers; the markdown target passes
--markdown-headings=atx.

Signed-off-by: Claude Fable 5.2 <agent@terwey.me>
@terwey
terwey merged commit 7830d81 into master Nov 16, 2026
5 checks passed
Sign up for free to 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.

2 participants