You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `parseURL` function yields an object for each row with the following properties:
36
+
-`row`: array of strings with the values of the row.
37
+
-`errors`: array of parsing errors found in the row.
38
+
-`meta`: object with metadata about the parsing process.
39
+
40
+
The format is described on the doc pages: https://severo.github.io/csv-range/interfaces/ParseResult.html.
41
+
42
+
The `row` field might contain fewer or more columns than expected, depending on the CSV content. It can be an empty array for empty rows. It's up to the user to handle these cases. The library does not trim whitespace from values, and it does not convert types.
43
+
44
+
The `errors` field contains any parsing errors found in the row. It's an array of error messages, which can be useful for debugging. See the possible errors in the doc pages: https://severo.github.io/csv-range/interfaces/ParseError.html.
45
+
46
+
The `meta` field provides the `delimiter` and `newline` strings, detected automatically, or specified by the user. It also gives the number of characters of the line (as counted by JavaScript) and the corresponding number of bytes in the original CSV file (which may differ due to multi-byte characters) and byte offset in the file. These counts include the newline characters.
47
+
48
+
### Options
49
+
50
+
The `parseURL` function accepts an optional second argument with options.
51
+
52
+
It can contain options for fetching the CSV file: https://severo.github.io/csv-range/interfaces/FetchOptions.html, for guessing the delimiter and newline characters: https://severo.github.io/csv-range/interfaces/GuessOptions.html, and for parsing the CSV content: https://severo.github.io/csv-range/interfaces/ParseOptions.html.
53
+
54
+
55
+
## Examples
56
+
57
+
Find some examples of usage below. You can also find them in the [examples](https://severo.github.io/csv-range/examples/) directory, and run them with `npm run examples`.
58
+
59
+
### Only the first 10 rows
60
+
61
+
As the library uses async iterators, it's easy to stop parsing after a certain number of rows:
Use the `result.meta.byteOffset` and `result.meta.byteCount` fields to know the exact byte range of each parsed row, and adjust your fetching strategy accordingly. See the [examples](https://severo.github.io/csv-range/examples/) for more details.
97
+
32
98
## Early version
33
99
34
100
This is an early version. The API may change completely:
@@ -37,6 +103,10 @@ This is an early version. The API may change completely:
37
103
- from version 0.1.0 to 1.0.0, breaking changes will be introduced only in minor versions.
38
104
- from version 1.0.0, breaking changes will be introduced only in major versions.
39
105
106
+
## Used by
107
+
108
+
This library is used by [source.coop](https://source.coop/severo/csv-papaparse-test-files/verylong-sample.csv) to preview the CSV files. More info in [csv-table](https://github.com/source-cooperative/csv-table/), which fetches ranges of the remote CSV to display the rows that are visible in the table. It also caches the fetched ranges to avoid re-fetching them when scrolling.
109
+
40
110
## Thanks
41
111
42
112
The code is heavily inspired by [Papaparse](https://www.papaparse.com/).
0 commit comments