The developer problem
Splitting each line on commas changes both field contents and record counts when a field contains a quoted comma or newline. RFC 4180 describes the quoting and doubled-quote rules that the Dipper parser uses.
Run the project locally
The importer preserves a literal quote in the first note and an embedded newline in the second. Give it a UTF-8 CSV file to check its width before reading the note column. Install Blyx 0.2.1, Rust and a host linker, then run these commands.
git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-dipper.git
cd blyx-dipper
blyxc native-run project.blyxUse the API
Parse a UTF-8 string in memory. Delimiters are commas. Records accept CRLF, LF or CR; embedded quoted newlines preserve their original bytes. Spaces are data. A malformed quote discards partial results. Empty input contains zero rows; a blank line holds one empty cell. di_bad_row applies a caller-supplied column count.
| Function | Behavior |
|---|---|
| di_parse(input), di_ok(records) | Import csv. Parse into F-prefixed field events and R end-of-row events. A lone E-prefixed event describes a syntax error. |
| di_cell(records, row, column) | Return one string for a present cell, including an empty cell; an absent cell returns an empty list. |
| di_bad_row(records, width) | Return the first zero-based row of the wrong width, −1 for success or −2 for a parse or argument error. |
| di_transition(state, token), di_shape(tokens) | Walk the portable quote state machine. A valid stream yields [rows, fields]. |
Verify a change
Run the package checks from its release directory. Compare the browser example with its expected output, then change the input in the exercise below.
blyxc native-run tests.blyxTry the program
Expected output
1 2 0
Practice
Append a third field before the final record break.
Hint
Change only the worked example’s input. The API table describes the output.
Worked solution
The extra delimiter is outside quotes, so the row now has three fields.
Find
[2, 0, 1, 0, 2, 1, 0, 3]Replace with
[2, 0, 1, 0, 2, 1, 0, 1, 0, 3]Output after the change
1 3 0
