|
4 | 4 | <br/><br/><br/><br/><br/><br/><br/> |
5 | 5 | <h1>CSV-Rex</h1> |
6 | 6 | <p>A tiny and fast CSV parser & formatter for JavaScript.</p> |
7 | | -<p>It's small hands are a feature.</p> |
8 | 7 | <br /> |
9 | 8 | <p> |
10 | 9 | <a href="https://www.npmjs.com/package/csv-rex?activeTab=versions"> |
|
36 | 35 | ## Features |
37 | 36 | - Free to use under MIT licence |
38 | 37 | - Comma-Separated Values (CSV) Files specification compliant ([RFC-4180](https://tools.ietf.org/html/rfc4180)) |
39 | | -- Small bundle size (0.5KB - 1KB compressed) |
| 38 | +- Small bundle size (~1KB compressed) |
40 | 39 | - Zero dependencies |
41 | 40 | - ESM & CJS modules with `.map` files |
42 | 41 | - NodeJS and WebStream API support via @datastream/csv |
@@ -83,18 +82,17 @@ Defaults are set to for performance and RFC-4180 compliance. |
83 | 82 | - `true`: First row of the `input` is the headers and will need to be pulled out |
84 | 83 | - `[...]`: Pre-assign headers because `input` contains no headers. |
85 | 84 | - `false`: Don't map to JSON, return array of values instead. |
86 | | -- `newlineChar` (`\n`): What `newline` character(s) to be used. |
87 | | -- `delimiterChar` (`,`): Characters used to separate fields |
| 85 | +- `newlineChar` (`\r\n`): What `newline` character(s) to be used. |
| 86 | +- `delimiterChar` (`,`): Characters used to separate fields. Must be length of 1 |
88 | 87 | - `quoteChar` (`"`): Character used to wrap fields that need to have special characters within them. Must be length of 1 |
89 | 88 | - `escapeChar` (`quoteChar`): Character used to escape the `quoteChar`. Must be length of 1 |
90 | 89 |
|
91 | 90 | ### Parse |
92 | 91 | - `enqueue` (`({data, idx, err}) => {}`): Function to run on parsed row data. |
93 | 92 | - `chunkSize` (`10MB`): Size of chunks to process at once. Should be greater than the size of the 3 largest lines. |
94 | | -- `fastMode` (`true`): Option to allow a faster parsing strategy when `quoteChar` is not present in a chunk. |
95 | | -- `commentPrefixValue` (false): Lines starting with this value will be ignored (i.e. `#`, `//`). Can be set to `false` if files will never have comments. |
96 | 93 | - `emptyFieldValue` (`<empty string>`): Value to be used instead of an empty string. Can be set to `undefined` to have empty fields not be included. |
97 | 94 | - `coerceField` (`(field) => field`): Function to apply type/value coercion. |
| 95 | +- `commentPrefixValue` (false): Lines starting with this value will be ignored (i.e. `#`, `//`). Can be set to `false` if files will never have comments. |
98 | 96 | - `errorOnEmptyLine` (`true`): When an empty line is encountered. Push row with error when occurs, row ignored otherwise. |
99 | 97 | - `errorOnComment` (`true`): When a comment is encountered. Push row with error when occurs, row ignored otherwise. |
100 | 98 | - `errorOnFieldsMismatch` (`true`): When number of headers does not match the number of fields in a row. Push row with error when occurs, row ignored otherwise. |
@@ -274,4 +272,4 @@ export const csvParseStream = (opts) => { |
274 | 272 | - [ ] Automate and publish benchmarks |
275 | 273 | - [ ] option functionality |
276 | 274 | - validate options |
277 | | - - autodetect options |
| 275 | + - autodetect options (newline/delimiter) |
0 commit comments