Repository navigation
feat: read the input with the dsv-parser library - #3
Merged
Merged
Conversation
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>
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.
What this is
csv2sqlite reads its input with dsv-parser v0.1.0, the parser of this repository moved into a library. The
parserpackage keeps the writing: the header, the rows, the part files and the merge.1bfc145Reader; removes the cutter, the splitters and their tests, which live in the library.1a8005c,4b7cb837281e71v0.1.0and writes one expected database again.4379324--chunk-sizeand--channel-capacityand the report fields that printed them.68883a7README.mdagain; themarkdowntarget works with pandoc 3.Without the generated
README.md: 4,097 lines go, 218 come.What changes for a user
--chunk-sizeand--channel-capacityare 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.chunksize,channel-capacityandcapacityof--csv-report(13 columns, were 16), andPerformance.Chunksize,Performance.CapacityandParams.ChannelCapacityof the JSON report.--threadsstill keeps one thread for the merge.--rowida 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:
000) no longer hides the enclosure of a later column."") is read with its enclosure: those fields are empty, they were the two characters"".--php. Three values oftests/csvSample.512034.11822895.csvchange from1\" ...to1" .... Its expected database is written again in7281e71; 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:4b7cb83, to SQLite4b7cb83,--drop(parse only)v0.23.1-rc, to SQLiteThe write to SQLite takes the same time; the parser is no longer what holds the memory.
Tested
go vetandgo testpass for every package of the module.go build ./cmd/csv2sqlitebuilds from a clean module cache with the released library;go.modholds no local replace.README.mdis the output ofmake markdownwith asciidoctor 2.0.23 and pandoc 3.1.11; its markup differs from the committed one because that was written by an older pandoc.