select-csv 1.1.20 → 1.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.md +86 -148
  3. package/package.json +37 -34
  4. package/selectcsv.js +254 -1288
package/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Housseyn Cheriet
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,22 +1,19 @@
1
- Parse CSV with JavaScript
2
- ========================================
3
-
4
- It is the fastest, simplest and most powerful package of all existing libraries in npmjs. It converts .csv files into an array and even into lines. It contains two important functions parseCsv that handles a csv file, you only need a link to the file. And parseText deals with text, and they both have the same roles and and methods, and it comes with these features:
5
-
6
- - Package with small content (< 30 KB)
7
- - Easy to use
8
- - Parse CSV files directly (local)
9
- - Fast mode
10
- - Stream large files
11
- - It is a synchronous package
12
- - Uses chunks
13
- - Uses row offset (get rows from line x to line x+n)
14
- - Returns rows (with columns) or lines (without columns)
15
- - No external dependencies
16
- - Flexible with lots of options (header, quote, line break, delimiter, bufferSize in CSV file, Rows in an array or json array)
17
- - One of the only parsers that correctly handles line-breaks and quotations
18
-
19
- select-csv has **no dependencies** .
1
+ # select-csv
2
+
3
+ The fastest, simplest, and most powerful CSV parser for Node.js. Optimized for high performance and extreme memory efficiency when handling massive datasets (100M+ rows).
4
+
5
+ `select-csv` converts `.csv` files into arrays, JSON objects, or raw lines. It provides two main functions, `parseCsv` (for local files) and `parseText` (for raw strings), both sharing the same methods and features.
6
+
7
+ ## Key Features
8
+ - **Ultra-Lightweight:** Package size is less than 30 KB.
9
+ - **Fast Mode:** Synchronous execution for maximum speed and zero overhead.
10
+ - **Memory Efficient:** Streams large files using chunks and row offsets instead of loading the entire file into RAM.
11
+ - **Robust Parsing:** Correct handling of complex line-breaks (`\r\n`, `\n`) and nested quotations.
12
+ - **No Dependencies:** Zero external dependencies for maximum security and stability.
13
+ - **Flexible Options:** Highly customizable (headers, quotes, delimiters, buffers).
14
+
15
+ ---
16
+
20
17
 
21
18
  Install:
22
19
  -------
@@ -58,38 +55,29 @@ parse = parseText(
58
55
  );
59
56
 
60
57
 
61
- ```
62
-
63
- * If you want to get just the header :
64
- ```js
65
- const result = parse.header();
66
- /*
67
- ["Index","User Id","First Name","Last Name","Sex"]
68
- */
69
-
70
58
  ```
71
59
 
72
60
  * If you want to get all rows :
73
61
  ```js
74
62
  const result = parse.get(); //Return all rows
75
63
  /*
76
- {
77
- time:'1 ms',
78
- header:["Index","User Id","First Name","Last Name","Sex"],
79
- rows:[
80
- ["1","5f10e9D33fC5f2b","Sara","Mcguire","Female"],
81
- ["2","751cD1cbF77e005","Alisha","Hebert","Male"],
82
- ["3","DcEFDB2D2e62bF9","Gwendolyn","Sheppard","Male"],
83
- ["4","C88661E02EEDA9e","Kristine","Mccann","Female"],
84
- ["5","fafF1aBDebaB2a6","Bobby","Pittman","Female"],
85
- ["6","BdDb6C8Af309202","Calvin","Ramsey","Female"],
86
- ["7","FCdfFf08196f633","Collin","Allison","Male"],
87
- ["8","356279dAa0F7CbD","Nicholas","Branch","Male"],
88
- ["9","F563CcbFBfEcf5a","Emma","Robinson","Female"],
89
- ["10","f2dceFc00F62542","Pedro","Cordova","Male"]
90
- ],
91
- row_count:10
92
- }
64
+ {
65
+ time:1,
66
+ header:["Index","User Id","First Name","Last Name","Sex"],
67
+ rows:[
68
+ ["1","5f10e9D33fC5f2b","Sara","Mcguire","Female"],
69
+ ["2","751cD1cbF77e005","Alisha","Hebert","Male"],
70
+ ["3","DcEFDB2D2e62bF9","Gwendolyn","Sheppard","Male"],
71
+ ["4","C88661E02EEDA9e","Kristine","Mccann","Female"],
72
+ ["5","fafF1aBDebaB2a6","Bobby","Pittman","Female"],
73
+ ["6","BdDb6C8Af309202","Calvin","Ramsey","Female"],
74
+ ["7","FCdfFf08196f633","Collin","Allison","Male"],
75
+ ["8","356279dAa0F7CbD","Nicholas","Branch","Male"],
76
+ ["9","F563CcbFBfEcf5a","Emma","Robinson","Female"],
77
+ ["10","f2dceFc00F62542","Pedro","Cordova","Male"]
78
+ ],
79
+ row_count:10
80
+ }
93
81
  */
94
82
 
95
83
  ```
@@ -105,9 +93,9 @@ result = parse.chunk(c)
105
93
  result = parse.chunk(2) //Return row 0 and 1
106
94
  /*
107
95
  {
108
- time: '0 ms',
109
- header: [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
110
- rows: [
96
+ "Time": 0,
97
+ "Header": [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
98
+ "Rows": [
111
99
  [ "1", "5f10e9D33fC5f2b", "Sara", "Mcguire", "Female" ],
112
100
  [ "2", "751cD1cbF77e005", "Alisha", "Hebert", "Male" ]
113
101
  ],
@@ -118,9 +106,9 @@ result = parse.chunk(2) //Return row 0 and 1
118
106
  result = parse.chunk(3) //Return row 2,3 and 4 (Get rows from last offset saved)
119
107
  /*
120
108
  {
121
- time: '0 ms',
122
- header: [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
123
- rows: [
109
+ "Time": 0,
110
+ "Header": [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
111
+ "Rows": [
124
112
  [ "3", "DcEFDB2D2e62bF9", "Gwendolyn", "Sheppard", "Male" ],
125
113
  [ "4", "C88661E02EEDA9e", "Kristine", "Mccann", "Female" ],
126
114
  [ "5", "fafF1aBDebaB2a6", "Bobby", "Pittman", "Female" ]
@@ -132,9 +120,9 @@ result = parse.chunk(3) //Return row 2,3 and 4 (Get rows from last offset saved)
132
120
  result = parse.chunk(1) //Return row 5 (Get rows from last offset saved)
133
121
  /*
134
122
  {
135
- time: '0 ms',
136
- header: [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
137
- rows: [
123
+ "Time": 0,
124
+ "Header": [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
125
+ "Rows": [
138
126
  [ "6", "BdDb6C8Af309202", "Calvin", "Ramsey", "Female" ]
139
127
  ],
140
128
  "row_count:": 1
@@ -159,9 +147,9 @@ result = parse.rowOffset(from,to)
159
147
  result = parse.rowOffset(6) //Returns all rows from the sixth row to the last row
160
148
  /*
161
149
  {
162
- time: '0 ms',
163
- header: [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
164
- rows: [
150
+ "Time": 0,
151
+ "Header": [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
152
+ "Rows": [
165
153
  [ "7", "FCdfFf08196f633", "Collin", "Allison", "Male" ],
166
154
  [ "8", "356279dAa0F7CbD", "Nicholas", "Branch", "Male" ],
167
155
  [ "9", "F563CcbFBfEcf5a", "Emma", "Robinson", "Female" ],
@@ -174,9 +162,9 @@ result = parse.rowOffset(6) //Returns all rows from the sixth row to the last ro
174
162
  result = parse.rowOffset(5,8) //Returns all rows from 5th to 8th row
175
163
  /*
176
164
  {
177
- time: '1 ms',
178
- header: [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
179
- rows: [
165
+ "Time": 1,
166
+ "Header": [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
167
+ "Rows": [
180
168
  [ "6", "BdDb6C8Af309202", "Calvin", "Ramsey", "Female" ],
181
169
  [ "7", "FCdfFf08196f633", "Collin", "Allison", "Male" ],
182
170
  [ "8", "356279dAa0F7CbD", "Nicholas", "Branch", "Male" ]
@@ -204,9 +192,9 @@ result = parse.setRowOffset(5)
204
192
  result = parse.chunk(1) // Get rows from last offset saved
205
193
  /*
206
194
  {
207
- time: '0 ms',
208
- header: [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
209
- rows: [
195
+ "Time": 0,
196
+ "Header": [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
197
+ "Rows": [
210
198
  [ "6", "BdDb6C8Af309202", "Calvin", "Ramsey", "Female" ]
211
199
  ],
212
200
  "row_count:": 1
@@ -221,9 +209,9 @@ false
221
209
  result = parse.chunk(1) // Get rows from last offset saved
222
210
  /*
223
211
  {
224
- time: '0 ms',
225
- header: [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
226
- rows: [
212
+ "Time": 0,
213
+ "Header": [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
214
+ "Rows": [
227
215
  [ "7", "FCdfFf08196f633", "Collin", "Allison", "Male" ]
228
216
  ],
229
217
  "row_count:": 1
@@ -237,26 +225,24 @@ result = parse.chunk(1) // Get rows from last offset saved
237
225
 
238
226
  ```js
239
227
  {
240
- 'header': true,
241
- 'quote': false,
242
- 'linebreak': '\r\n',
243
- 'delimiter': ",",
244
- 'json': false,
228
+ 'header': true,
229
+ 'quote': false,
230
+ 'linebreak': '\r\n',
231
+ 'delimiter': ",",
245
232
  'bufferSize':1024*1024
246
233
  }
247
- // delimiter: (String: get rows containing columns, false: get lines without columns)
234
+ // delimiter: (String: get rows containing columns, false: get lines without columns)
248
235
  //bufferSize: It only works with a CSV file, which is the maximum number of characters that can be read at a time, the minimum value is 1024
249
236
  ```
250
237
 
251
238
  * If you want to use specific option :
252
239
  ```js
253
240
  var option = {
254
- 'header': false, /* or true */
255
- 'quote': true, /* or false */
256
- 'linebreak': '\n', /* '\n' or '\r' or any other string */
257
- 'delimiter': "," /* ';' or any other string or false */
258
- 'json': false /* or true */
259
- 'bufferSize':2000 /* It only works with a CSV file */
241
+ 'header': false, /* or true */
242
+ 'quote': true, /* or false */
243
+ 'linebreak': '\n', /* '\n' or '\r' or any other string */
244
+ 'delimiter': "," /* ';' or any other string or false */
245
+ 'bufferSize':2000 /* It only works with a CSV file */
260
246
  }
261
247
 
262
248
  var parse;
@@ -271,13 +257,16 @@ parse = parseText(
271
257
  3,DcEFDB2D2e62bF9,Gwendolyn,Sheppard,Male`
272
258
  , option);
273
259
 
260
+ option = {
261
+ 'header': false,
262
+ }
274
263
 
275
264
  result = parse.rowOffset(2)
276
265
  /*
277
266
  {
278
- time: '0 ms',
279
- header: false,
280
- rows: [
267
+ "Time": 0,
268
+ "Header": false,
269
+ "Rows": [
281
270
  [ "2", "751cD1cbF77e005", "Alisha", "Hebert", "Male" ]
282
271
  ],
283
272
  "row_count:": 1
@@ -285,15 +274,15 @@ result = parse.rowOffset(2)
285
274
  */
286
275
 
287
276
  option = {
288
- 'header': true,
289
- 'delimiter': false
277
+ 'header': true,
278
+ 'delimiter': false
290
279
  }
291
- // delimiter: (String: get rows containing columns, false: get lines without columns)
280
+ // delimiter: (String: get rows containing columns, false: get lines without columns)
292
281
  /*
293
282
  {
294
- time: '0 ms',
295
- header: false,
296
- rows: [
283
+ "Time": 0,
284
+ "Header": false,
285
+ "Rows": [
297
286
  [ "2,751cD1cbF77e005,Alisha,Hebert,Male" ] // No columns, just string (all line)
298
287
  ],
299
288
  "row_count:": 1
@@ -305,58 +294,14 @@ option = {
305
294
  * If you want to reset option after multiple uses of your code :
306
295
  ```js
307
296
  const option = { // Just an exapmle
308
- 'header': false,
309
- 'quote': true,
310
- 'linebreak': '\n'
297
+ 'header': false,
298
+ 'quote': true,
299
+ 'linebreak': '\n'
311
300
  }
312
301
 
313
302
  parse.resetOption(option); // All saved values are erased and the object is restared again
314
303
 
315
304
 
316
- ```
317
-
318
- * If you want to rows as json array :
319
- ```js
320
- // 'header' and 'json' must be true if you want to get rows as a json array
321
- const option = {
322
- 'header': true,
323
- 'json': true
324
- }
325
-
326
-
327
- const result = parse.chunk(3)
328
- /*
329
- {
330
- time: '0 ms',
331
- header: [ 'Index', 'User Id', 'First Name', 'Last Name', 'Sex' ],
332
- rows: [
333
- {
334
- Index: '1',
335
- 'User Id': '5f10e9D33fC5f2b',
336
- 'First Name': 'Sara',
337
- 'Last Name': 'Mcguire',
338
- Sex: 'Female'
339
- },
340
- {
341
- Index: '2',
342
- 'User Id': '751cD1cbF77e005',
343
- 'First Name': 'Alisha',
344
- 'Last Name': 'Hebert',
345
- Sex: 'Male'
346
- },
347
- {
348
- Index: '3',
349
- 'User Id': 'DcEFDB2D2e62bF9',
350
- 'First Name': 'Gwendolyn',
351
- 'Last Name': 'Sheppard',
352
- Sex: 'Male'
353
- }
354
- ],
355
- row_count: 3
356
- }
357
- */
358
-
359
-
360
305
  ```
361
306
 
362
307
  * If you want to get information of your object :
@@ -389,7 +334,7 @@ var result;
389
334
  result = parse.chunk(100000)
390
335
  /*
391
336
  {
392
- time: '222 ms',
337
+ time: 222,
393
338
  header: false,
394
339
  rows: [
395
340
  [ '198801', '1', '103', '100', '000000190', '0', '35843', '34353' ],
@@ -419,7 +364,7 @@ result = parse.chunk(100000)
419
364
  result = parse.chunk(3) // Return row 100001,100002 and 100003 (Get rows from last offset saved)
420
365
  /*
421
366
  {
422
- time: '1 ms',
367
+ time: 1,
423
368
  header: false,
424
369
  rows: [
425
370
  [ '198801', '1', '326', '500', '841330000', '90', '81', '246' ],
@@ -435,7 +380,7 @@ const to = from + 5;
435
380
  result = parse.rowOffset(from,to)
436
381
  /*
437
382
  {
438
- time: '3743 ms',
383
+ time: 3743,
439
384
  header: false,
440
385
  rows: [
441
386
  [
@@ -458,7 +403,7 @@ const to = from + 4;
458
403
  result = parse.rowOffset(from,to)
459
404
  /*
460
405
  {
461
- time: '44126 ms',
406
+ time: 44126,
462
407
  header: false,
463
408
  rows: [
464
409
  [ '201412', '1', '125', '400', '283525000', '0', '160000', '6492' ],
@@ -473,7 +418,7 @@ result = parse.rowOffset(from,to)
473
418
  result = parse.chunk(3) // Get rows from last offset saved ( row to,to+1 and to+2 )
474
419
  /*
475
420
  {
476
- time: '29 ms',
421
+ time: 29,
477
422
  header: false,
478
423
  rows: [
479
424
  [ '201412', '1', '125', '400', '400932000', '0', '18', '526' ],
@@ -500,13 +445,6 @@ result = parse.getInfo() // Get all the information
500
445
  */
501
446
  ```
502
447
 
503
- ## Request Features or Report Bugs
504
-
505
- Feature requests and bug reports are very welcome: https://github.com/housseynCheriet/select-csv/issues
506
-
507
- A couple of requests from me when you raise an issue on GitHub.
448
+ ## 📄 License
508
449
 
509
- * **Requesting a feature:** Please try to provide the context of why you want the feature. Such as,
510
- in what situation the feature could help you and how, or how the lack of the feature is causing an inconvenience to you.
511
- I can't start thinking of introducing it until I understand how it helps you 🙂
512
- * **Reporting a bug:** If you could provide a runnable code snippet that reproduces the bug, it would be very helpful!
450
+ MIT License
package/package.json CHANGED
@@ -1,34 +1,37 @@
1
- {
2
- "name": "select-csv",
3
- "version": "1.1.20",
4
- "description": "Fastest, simplest and most powerful package of all existing libraries in npmjs. It converts .csv files into an array and even into lines. It contains two important functions parseCsv that handles a csv file, you only need a link to the file. And parseText deals with text, and they both have the same roles and and methods",
5
- "keywords": [
6
- "csv",
7
- "parser",
8
- "parse",
9
- "parsing",
10
- "delimited",
11
- "text",
12
- "data",
13
- "comma",
14
- "tab",
15
- "pipe",
16
- "file",
17
- "filereader",
18
- "stream",
19
- "chunk",
20
- "line"
21
- ],
22
- "author": {
23
- "name": "Housseyn Cheriet",
24
- "url": "https://github.com/housseynCheriet"
25
- },
26
- "repository": {
27
- "type": "git",
28
- "url": "https://github.com/housseynCheriet/select-csv"
29
- },
30
- "license": "CC-BY-ND",
31
- "main": "selectcsv.js",
32
- "scripts": {}
33
-
34
- }
1
+ {
2
+ "name": "select-csv",
3
+ "version": "1.1.22",
4
+ "description": "A high-performance, memory-efficient CSV parser for Node.js. Supports streaming large files via chunks and row offsets with zero dependencies.",
5
+ "keywords": [
6
+ "csv",
7
+ "parser",
8
+ "parse",
9
+ "parsing",
10
+ "delimited",
11
+ "text",
12
+ "data",
13
+ "comma",
14
+ "tab",
15
+ "pipe",
16
+ "file",
17
+ "filereader",
18
+ "stream",
19
+ "chunk",
20
+ "line",
21
+ "fast-csv",
22
+ "large-file"
23
+ ],
24
+ "author": {
25
+ "name": "Housseyn Cheriet",
26
+ "url": "https://github.com/housseynCheriet"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/housseynCheriet/select-csv"
31
+ },
32
+ "license": "MIT",
33
+ "main": "selectcsv.js",
34
+ "scripts": {
35
+ "test": "echo \"Error: no test specified\" && exit 1"
36
+ }
37
+ }