convert-csv-to-json 4.1.0 → 4.3.0

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 (61) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc.json +48 -0
  3. package/.github/workflows/ci-cd.yml +28 -2
  4. package/SECURITY.md +2 -0
  5. package/docs/api/BrowserApi.html +2435 -0
  6. package/docs/api/BrowserApiError.html +522 -0
  7. package/docs/api/ConfigurationError.html +594 -0
  8. package/docs/api/CsvFormatError.html +530 -0
  9. package/docs/api/CsvParsingError.html +384 -0
  10. package/docs/api/CsvToJson.html +3136 -0
  11. package/docs/api/CsvToJsonAsync.html +2672 -0
  12. package/docs/api/FileOperationError.html +270 -0
  13. package/docs/api/FileUtils.html +1012 -0
  14. package/docs/api/InputValidationError.html +293 -0
  15. package/docs/api/JsonUtil.html +340 -0
  16. package/docs/api/JsonValidationError.html +247 -0
  17. package/docs/api/fonts/OpenSans-Bold-webfont.eot +0 -0
  18. package/docs/api/fonts/OpenSans-Bold-webfont.svg +1830 -0
  19. package/docs/api/fonts/OpenSans-Bold-webfont.woff +0 -0
  20. package/docs/api/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  21. package/docs/api/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  22. package/docs/api/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  23. package/docs/api/fonts/OpenSans-Italic-webfont.eot +0 -0
  24. package/docs/api/fonts/OpenSans-Italic-webfont.svg +1830 -0
  25. package/docs/api/fonts/OpenSans-Italic-webfont.woff +0 -0
  26. package/docs/api/fonts/OpenSans-Light-webfont.eot +0 -0
  27. package/docs/api/fonts/OpenSans-Light-webfont.svg +1831 -0
  28. package/docs/api/fonts/OpenSans-Light-webfont.woff +0 -0
  29. package/docs/api/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  30. package/docs/api/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  31. package/docs/api/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  32. package/docs/api/fonts/OpenSans-Regular-webfont.eot +0 -0
  33. package/docs/api/fonts/OpenSans-Regular-webfont.svg +1831 -0
  34. package/docs/api/fonts/OpenSans-Regular-webfont.woff +0 -0
  35. package/docs/api/global.html +3315 -0
  36. package/docs/api/index.html +326 -0
  37. package/docs/api/index.js.html +341 -0
  38. package/docs/api/scripts/linenumber.js +25 -0
  39. package/docs/api/scripts/prettify/Apache-License-2.0.txt +202 -0
  40. package/docs/api/scripts/prettify/lang-css.js +2 -0
  41. package/docs/api/scripts/prettify/prettify.js +28 -0
  42. package/docs/api/src_browserApi.js.html +271 -0
  43. package/docs/api/src_csvToJson.js.html +605 -0
  44. package/docs/api/src_csvToJsonAsync.js.html +244 -0
  45. package/docs/api/src_util_errors.js.html +374 -0
  46. package/docs/api/src_util_fileUtils.js.html +147 -0
  47. package/docs/api/src_util_jsonUtils.js.html +75 -0
  48. package/docs/api/src_util_stringUtils.js.html +212 -0
  49. package/docs/api/styles/jsdoc-default.css +358 -0
  50. package/docs/api/styles/prettify-jsdoc.css +111 -0
  51. package/docs/api/styles/prettify-tomorrow.css +132 -0
  52. package/index.js +109 -32
  53. package/jsdoc.json +17 -0
  54. package/package.json +10 -3
  55. package/src/browserApi.js +96 -4
  56. package/src/csvToJson.js +163 -2
  57. package/src/csvToJsonAsync.js +74 -14
  58. package/src/util/errors.js +96 -0
  59. package/src/util/fileUtils.js +34 -0
  60. package/src/util/jsonUtils.js +8 -0
  61. package/src/util/stringUtils.js +51 -0
@@ -0,0 +1,3315 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Global</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"> </script>
8
+ <script src="scripts/prettify/lang-css.js"> </script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="main">
19
+
20
+ <h1 class="page-title">Global</h1>
21
+
22
+
23
+
24
+
25
+
26
+
27
+ <section>
28
+
29
+ <header>
30
+
31
+ <h2></h2>
32
+
33
+
34
+ </header>
35
+
36
+ <article>
37
+ <div class="container-overview">
38
+
39
+
40
+
41
+
42
+
43
+
44
+ <dl class="details">
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+ </dl>
78
+
79
+
80
+
81
+
82
+ </div>
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ <h3 class="subsection-title">Members</h3>
98
+
99
+
100
+
101
+ <h4 class="name" id="browser"><span class="type-signature"></span>browser<span class="type-signature"></span></h4>
102
+
103
+
104
+
105
+
106
+ <div class="description">
107
+ <p>Browser API
108
+ Provides parsing helpers suitable for browser environments (parsing strings and File/Blob objects)</p>
109
+ </div>
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+ <dl class="details">
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+ <dt class="tag-source">Source:</dt>
145
+ <dd class="tag-source"><ul class="dummy"><li>
146
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line290">line 290</a>
147
+ </li></ul></dd>
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+ </dl>
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+ <h4 class="name" id="csvToJsonAsync"><span class="type-signature">(constant) </span>csvToJsonAsync<span class="type-signature"></span></h4>
165
+
166
+
167
+
168
+
169
+ <div class="description">
170
+ <p>Parse CSV file asynchronously and return parsed data as JSON array</p>
171
+ </div>
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+ <dl class="details">
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+ <dt class="tag-source">Source:</dt>
207
+ <dd class="tag-source"><ul class="dummy"><li>
208
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line236">line 236</a>
209
+ </li></ul></dd>
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+ </dl>
218
+
219
+
220
+
221
+
222
+
223
+ <h5>Example</h5>
224
+
225
+ <pre class="prettyprint"><code>const csvToJson = require('convert-csv-to-json');
226
+ const data = await csvToJson.getJsonFromCsvAsync('resource/input.csv');
227
+ console.log(data);</code></pre>
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+ <h3 class="subsection-title">Methods</h3>
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+ <h4 class="name" id="asciiEncoding"><span class="type-signature"></span>asciiEncoding<span class="signature">()</span><span class="type-signature"> &rarr; {object}</span></h4>
244
+
245
+
246
+
247
+
248
+
249
+
250
+ <div class="description">
251
+ <p>Set ASCII encoding for reading files</p>
252
+ </div>
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+ <dl class="details">
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+ <dt class="tag-source">Source:</dt>
294
+ <dd class="tag-source"><ul class="dummy"><li>
295
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line143">line 143</a>
296
+ </li></ul></dd>
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+ </dl>
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+ <h5>Returns:</h5>
321
+
322
+
323
+ <div class="param-desc">
324
+ <p>Module context for method chaining</p>
325
+ </div>
326
+
327
+
328
+
329
+ <dl>
330
+ <dt>
331
+ Type
332
+ </dt>
333
+ <dd>
334
+
335
+ <span class="param-type">object</span>
336
+
337
+
338
+ </dd>
339
+ </dl>
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+
352
+
353
+ <h4 class="name" id="base64Encoding"><span class="type-signature"></span>base64Encoding<span class="signature">()</span><span class="type-signature"> &rarr; {object}</span></h4>
354
+
355
+
356
+
357
+
358
+
359
+
360
+ <div class="description">
361
+ <p>Set Base64 encoding for reading files</p>
362
+ </div>
363
+
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+ <dl class="details">
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+
386
+
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+ <dt class="tag-source">Source:</dt>
404
+ <dd class="tag-source"><ul class="dummy"><li>
405
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line152">line 152</a>
406
+ </li></ul></dd>
407
+
408
+
409
+
410
+
411
+
412
+
413
+
414
+ </dl>
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+ <h5>Returns:</h5>
431
+
432
+
433
+ <div class="param-desc">
434
+ <p>Module context for method chaining</p>
435
+ </div>
436
+
437
+
438
+
439
+ <dl>
440
+ <dt>
441
+ Type
442
+ </dt>
443
+ <dd>
444
+
445
+ <span class="param-type">object</span>
446
+
447
+
448
+ </dd>
449
+ </dl>
450
+
451
+
452
+
453
+
454
+
455
+
456
+
457
+
458
+
459
+
460
+
461
+
462
+
463
+ <h4 class="name" id="csvStringToJson"><span class="type-signature"></span>csvStringToJson<span class="signature">(csvString)</span><span class="type-signature"> &rarr; {Array.&lt;object>}</span></h4>
464
+
465
+
466
+
467
+
468
+
469
+
470
+ <div class="description">
471
+ <p>Parse a CSV string and return as JSON array of objects (synchronous)</p>
472
+ </div>
473
+
474
+
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+ <h5>Parameters:</h5>
483
+
484
+
485
+ <table class="params">
486
+ <thead>
487
+ <tr>
488
+
489
+ <th>Name</th>
490
+
491
+
492
+ <th>Type</th>
493
+
494
+
495
+
496
+
497
+
498
+ <th class="last">Description</th>
499
+ </tr>
500
+ </thead>
501
+
502
+ <tbody>
503
+
504
+
505
+ <tr>
506
+
507
+ <td class="name"><code>csvString</code></td>
508
+
509
+
510
+ <td class="type">
511
+
512
+
513
+ <span class="param-type">string</span>
514
+
515
+
516
+
517
+ </td>
518
+
519
+
520
+
521
+
522
+
523
+ <td class="description last"><p>CSV content as string</p></td>
524
+ </tr>
525
+
526
+
527
+ </tbody>
528
+ </table>
529
+
530
+
531
+
532
+
533
+
534
+
535
+ <dl class="details">
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+
549
+
550
+
551
+
552
+
553
+
554
+
555
+
556
+
557
+
558
+
559
+
560
+
561
+
562
+ <dt class="tag-source">Source:</dt>
563
+ <dd class="tag-source"><ul class="dummy"><li>
564
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line265">line 265</a>
565
+ </li></ul></dd>
566
+
567
+
568
+
569
+
570
+
571
+
572
+
573
+ </dl>
574
+
575
+
576
+
577
+
578
+
579
+
580
+
581
+
582
+
583
+
584
+
585
+
586
+
587
+ <h5>Throws:</h5>
588
+ <ul>
589
+ <li>
590
+
591
+ <dl>
592
+ <dt>
593
+ <div class="param-desc">
594
+ <p>If csvString is invalid</p>
595
+ </div>
596
+ </dt>
597
+ <dd></dd>
598
+ <dt>
599
+ <dl>
600
+ <dt>
601
+ Type
602
+ </dt>
603
+ <dd>
604
+
605
+ <span class="param-type"><a href="InputValidationError.html">InputValidationError</a></span>
606
+
607
+
608
+ </dd>
609
+ </dl>
610
+ </dt>
611
+ <dd></dd>
612
+ </dl>
613
+
614
+ </li>
615
+
616
+ <li>
617
+
618
+ <dl>
619
+ <dt>
620
+ <div class="param-desc">
621
+ <p>If CSV is malformed</p>
622
+ </div>
623
+ </dt>
624
+ <dd></dd>
625
+ <dt>
626
+ <dl>
627
+ <dt>
628
+ Type
629
+ </dt>
630
+ <dd>
631
+
632
+ <span class="param-type"><a href="CsvFormatError.html">CsvFormatError</a></span>
633
+
634
+
635
+ </dd>
636
+ </dl>
637
+ </dt>
638
+ <dd></dd>
639
+ </dl>
640
+
641
+ </li>
642
+ </ul>
643
+
644
+
645
+ <h5>Returns:</h5>
646
+
647
+
648
+ <div class="param-desc">
649
+ <p>Array of objects representing CSV rows</p>
650
+ </div>
651
+
652
+
653
+
654
+ <dl>
655
+ <dt>
656
+ Type
657
+ </dt>
658
+ <dd>
659
+
660
+ <span class="param-type">Array.&lt;object></span>
661
+
662
+
663
+ </dd>
664
+ </dl>
665
+
666
+
667
+
668
+
669
+
670
+
671
+ <h5>Example</h5>
672
+
673
+ <pre class="prettyprint"><code>const csvToJson = require('convert-csv-to-json');
674
+ const rows = csvToJson.csvStringToJson('name,age\nAlice,30');
675
+ console.log(rows); // [{ name: 'Alice', age: '30' }]</code></pre>
676
+
677
+
678
+
679
+
680
+
681
+
682
+
683
+
684
+
685
+ <h4 class="name" id="csvStringToJsonStringified"><span class="type-signature"></span>csvStringToJsonStringified<span class="signature">(csvString)</span><span class="type-signature"> &rarr; {string}</span></h4>
686
+
687
+
688
+
689
+
690
+
691
+
692
+ <div class="description">
693
+ <p>Parse CSV string and return as stringified JSON (synchronous)</p>
694
+ </div>
695
+
696
+
697
+
698
+
699
+
700
+
701
+
702
+
703
+
704
+ <h5>Parameters:</h5>
705
+
706
+
707
+ <table class="params">
708
+ <thead>
709
+ <tr>
710
+
711
+ <th>Name</th>
712
+
713
+
714
+ <th>Type</th>
715
+
716
+
717
+
718
+
719
+
720
+ <th class="last">Description</th>
721
+ </tr>
722
+ </thead>
723
+
724
+ <tbody>
725
+
726
+
727
+ <tr>
728
+
729
+ <td class="name"><code>csvString</code></td>
730
+
731
+
732
+ <td class="type">
733
+
734
+
735
+ <span class="param-type">string</span>
736
+
737
+
738
+
739
+ </td>
740
+
741
+
742
+
743
+
744
+
745
+ <td class="description last"><p>CSV content as string</p></td>
746
+ </tr>
747
+
748
+
749
+ </tbody>
750
+ </table>
751
+
752
+
753
+
754
+
755
+
756
+
757
+ <dl class="details">
758
+
759
+
760
+
761
+
762
+
763
+
764
+
765
+
766
+
767
+
768
+
769
+
770
+
771
+
772
+
773
+
774
+
775
+
776
+
777
+
778
+
779
+
780
+
781
+
782
+
783
+
784
+ <dt class="tag-source">Source:</dt>
785
+ <dd class="tag-source"><ul class="dummy"><li>
786
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line277">line 277</a>
787
+ </li></ul></dd>
788
+
789
+
790
+
791
+
792
+
793
+
794
+
795
+ </dl>
796
+
797
+
798
+
799
+
800
+
801
+
802
+
803
+
804
+
805
+
806
+
807
+
808
+
809
+ <h5>Throws:</h5>
810
+ <ul>
811
+ <li>
812
+
813
+ <dl>
814
+ <dt>
815
+ <div class="param-desc">
816
+ <p>If csvString is invalid</p>
817
+ </div>
818
+ </dt>
819
+ <dd></dd>
820
+ <dt>
821
+ <dl>
822
+ <dt>
823
+ Type
824
+ </dt>
825
+ <dd>
826
+
827
+ <span class="param-type"><a href="InputValidationError.html">InputValidationError</a></span>
828
+
829
+
830
+ </dd>
831
+ </dl>
832
+ </dt>
833
+ <dd></dd>
834
+ </dl>
835
+
836
+ </li>
837
+
838
+ <li>
839
+
840
+ <dl>
841
+ <dt>
842
+ <div class="param-desc">
843
+ <p>If CSV is malformed</p>
844
+ </div>
845
+ </dt>
846
+ <dd></dd>
847
+ <dt>
848
+ <dl>
849
+ <dt>
850
+ Type
851
+ </dt>
852
+ <dd>
853
+
854
+ <span class="param-type"><a href="CsvFormatError.html">CsvFormatError</a></span>
855
+
856
+
857
+ </dd>
858
+ </dl>
859
+ </dt>
860
+ <dd></dd>
861
+ </dl>
862
+
863
+ </li>
864
+
865
+ <li>
866
+
867
+ <dl>
868
+ <dt>
869
+ <div class="param-desc">
870
+ <p>If JSON generation fails</p>
871
+ </div>
872
+ </dt>
873
+ <dd></dd>
874
+ <dt>
875
+ <dl>
876
+ <dt>
877
+ Type
878
+ </dt>
879
+ <dd>
880
+
881
+ <span class="param-type"><a href="JsonValidationError.html">JsonValidationError</a></span>
882
+
883
+
884
+ </dd>
885
+ </dl>
886
+ </dt>
887
+ <dd></dd>
888
+ </dl>
889
+
890
+ </li>
891
+ </ul>
892
+
893
+
894
+ <h5>Returns:</h5>
895
+
896
+
897
+ <div class="param-desc">
898
+ <p>JSON stringified array of objects</p>
899
+ </div>
900
+
901
+
902
+
903
+ <dl>
904
+ <dt>
905
+ Type
906
+ </dt>
907
+ <dd>
908
+
909
+ <span class="param-type">string</span>
910
+
911
+
912
+ </dd>
913
+ </dl>
914
+
915
+
916
+
917
+
918
+
919
+
920
+
921
+
922
+
923
+
924
+
925
+
926
+
927
+ <h4 class="name" id="customEncoding"><span class="type-signature"></span>customEncoding<span class="signature">(encoding)</span><span class="type-signature"> &rarr; {object}</span></h4>
928
+
929
+
930
+
931
+
932
+
933
+
934
+ <div class="description">
935
+ <p>Set custom file encoding for reading CSV files
936
+ Useful for non-UTF8 encoded files</p>
937
+ </div>
938
+
939
+
940
+
941
+
942
+
943
+
944
+
945
+
946
+
947
+ <h5>Parameters:</h5>
948
+
949
+
950
+ <table class="params">
951
+ <thead>
952
+ <tr>
953
+
954
+ <th>Name</th>
955
+
956
+
957
+ <th>Type</th>
958
+
959
+
960
+
961
+
962
+
963
+ <th class="last">Description</th>
964
+ </tr>
965
+ </thead>
966
+
967
+ <tbody>
968
+
969
+
970
+ <tr>
971
+
972
+ <td class="name"><code>encoding</code></td>
973
+
974
+
975
+ <td class="type">
976
+
977
+
978
+ <span class="param-type">string</span>
979
+
980
+
981
+
982
+ </td>
983
+
984
+
985
+
986
+
987
+
988
+ <td class="description last"><p>Node.js supported encoding (e.g., 'utf8', 'latin1', 'ascii')</p></td>
989
+ </tr>
990
+
991
+
992
+ </tbody>
993
+ </table>
994
+
995
+
996
+
997
+
998
+
999
+
1000
+ <dl class="details">
1001
+
1002
+
1003
+
1004
+
1005
+
1006
+
1007
+
1008
+
1009
+
1010
+
1011
+
1012
+
1013
+
1014
+
1015
+
1016
+
1017
+
1018
+
1019
+
1020
+
1021
+
1022
+
1023
+
1024
+
1025
+
1026
+
1027
+ <dt class="tag-source">Source:</dt>
1028
+ <dd class="tag-source"><ul class="dummy"><li>
1029
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line98">line 98</a>
1030
+ </li></ul></dd>
1031
+
1032
+
1033
+
1034
+
1035
+
1036
+
1037
+
1038
+ </dl>
1039
+
1040
+
1041
+
1042
+
1043
+
1044
+
1045
+
1046
+
1047
+
1048
+
1049
+
1050
+
1051
+
1052
+
1053
+
1054
+ <h5>Returns:</h5>
1055
+
1056
+
1057
+ <div class="param-desc">
1058
+ <p>Module context for method chaining</p>
1059
+ </div>
1060
+
1061
+
1062
+
1063
+ <dl>
1064
+ <dt>
1065
+ Type
1066
+ </dt>
1067
+ <dd>
1068
+
1069
+ <span class="param-type">object</span>
1070
+
1071
+
1072
+ </dd>
1073
+ </dl>
1074
+
1075
+
1076
+
1077
+
1078
+
1079
+
1080
+
1081
+
1082
+
1083
+
1084
+
1085
+
1086
+
1087
+ <h4 class="name" id="fieldDelimiter"><span class="type-signature"></span>fieldDelimiter<span class="signature">(delimiter)</span><span class="type-signature"> &rarr; {object}</span></h4>
1088
+
1089
+
1090
+
1091
+
1092
+
1093
+
1094
+ <div class="description">
1095
+ <p>Set the field delimiter character used to separate CSV fields</p>
1096
+ </div>
1097
+
1098
+
1099
+
1100
+
1101
+
1102
+
1103
+
1104
+
1105
+
1106
+ <h5>Parameters:</h5>
1107
+
1108
+
1109
+ <table class="params">
1110
+ <thead>
1111
+ <tr>
1112
+
1113
+ <th>Name</th>
1114
+
1115
+
1116
+ <th>Type</th>
1117
+
1118
+
1119
+
1120
+
1121
+
1122
+ <th class="last">Description</th>
1123
+ </tr>
1124
+ </thead>
1125
+
1126
+ <tbody>
1127
+
1128
+
1129
+ <tr>
1130
+
1131
+ <td class="name"><code>delimiter</code></td>
1132
+
1133
+
1134
+ <td class="type">
1135
+
1136
+
1137
+ <span class="param-type">string</span>
1138
+
1139
+
1140
+
1141
+ </td>
1142
+
1143
+
1144
+
1145
+
1146
+
1147
+ <td class="description last"><p>Character(s) to use as field separator (default: ',')</p></td>
1148
+ </tr>
1149
+
1150
+
1151
+ </tbody>
1152
+ </table>
1153
+
1154
+
1155
+
1156
+
1157
+
1158
+
1159
+ <dl class="details">
1160
+
1161
+
1162
+
1163
+
1164
+
1165
+
1166
+
1167
+
1168
+
1169
+
1170
+
1171
+
1172
+
1173
+
1174
+
1175
+
1176
+
1177
+
1178
+
1179
+
1180
+
1181
+
1182
+
1183
+
1184
+
1185
+
1186
+ <dt class="tag-source">Source:</dt>
1187
+ <dd class="tag-source"><ul class="dummy"><li>
1188
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line48">line 48</a>
1189
+ </li></ul></dd>
1190
+
1191
+
1192
+
1193
+
1194
+
1195
+
1196
+
1197
+ </dl>
1198
+
1199
+
1200
+
1201
+
1202
+
1203
+
1204
+
1205
+
1206
+
1207
+
1208
+
1209
+
1210
+
1211
+
1212
+
1213
+ <h5>Returns:</h5>
1214
+
1215
+
1216
+ <div class="param-desc">
1217
+ <p>Module context for method chaining</p>
1218
+ </div>
1219
+
1220
+
1221
+
1222
+ <dl>
1223
+ <dt>
1224
+ Type
1225
+ </dt>
1226
+ <dd>
1227
+
1228
+ <span class="param-type">object</span>
1229
+
1230
+
1231
+ </dd>
1232
+ </dl>
1233
+
1234
+
1235
+
1236
+
1237
+
1238
+
1239
+
1240
+
1241
+
1242
+
1243
+
1244
+
1245
+
1246
+ <h4 class="name" id="formatValueByType"><span class="type-signature"></span>formatValueByType<span class="signature">(active)</span><span class="type-signature"> &rarr; {object}</span></h4>
1247
+
1248
+
1249
+
1250
+
1251
+
1252
+
1253
+ <div class="description">
1254
+ <p>Enable or disable automatic type formatting for values
1255
+ Converts numeric strings to numbers, 'true'/'false' to booleans</p>
1256
+ </div>
1257
+
1258
+
1259
+
1260
+
1261
+
1262
+
1263
+
1264
+
1265
+
1266
+ <h5>Parameters:</h5>
1267
+
1268
+
1269
+ <table class="params">
1270
+ <thead>
1271
+ <tr>
1272
+
1273
+ <th>Name</th>
1274
+
1275
+
1276
+ <th>Type</th>
1277
+
1278
+
1279
+
1280
+
1281
+
1282
+ <th class="last">Description</th>
1283
+ </tr>
1284
+ </thead>
1285
+
1286
+ <tbody>
1287
+
1288
+
1289
+ <tr>
1290
+
1291
+ <td class="name"><code>active</code></td>
1292
+
1293
+
1294
+ <td class="type">
1295
+
1296
+
1297
+ <span class="param-type">boolean</span>
1298
+
1299
+
1300
+
1301
+ </td>
1302
+
1303
+
1304
+
1305
+
1306
+
1307
+ <td class="description last"><p>Whether to format values by type (default: true)</p></td>
1308
+ </tr>
1309
+
1310
+
1311
+ </tbody>
1312
+ </table>
1313
+
1314
+
1315
+
1316
+
1317
+
1318
+
1319
+ <dl class="details">
1320
+
1321
+
1322
+
1323
+
1324
+
1325
+
1326
+
1327
+
1328
+
1329
+
1330
+
1331
+
1332
+
1333
+
1334
+
1335
+
1336
+
1337
+
1338
+
1339
+
1340
+
1341
+
1342
+
1343
+
1344
+
1345
+
1346
+ <dt class="tag-source">Source:</dt>
1347
+ <dd class="tag-source"><ul class="dummy"><li>
1348
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line28">line 28</a>
1349
+ </li></ul></dd>
1350
+
1351
+
1352
+
1353
+
1354
+
1355
+
1356
+
1357
+ </dl>
1358
+
1359
+
1360
+
1361
+
1362
+
1363
+
1364
+
1365
+
1366
+
1367
+
1368
+
1369
+
1370
+
1371
+
1372
+
1373
+ <h5>Returns:</h5>
1374
+
1375
+
1376
+ <div class="param-desc">
1377
+ <p>Module context for method chaining</p>
1378
+ </div>
1379
+
1380
+
1381
+
1382
+ <dl>
1383
+ <dt>
1384
+ Type
1385
+ </dt>
1386
+ <dd>
1387
+
1388
+ <span class="param-type">object</span>
1389
+
1390
+
1391
+ </dd>
1392
+ </dl>
1393
+
1394
+
1395
+
1396
+
1397
+
1398
+
1399
+
1400
+
1401
+
1402
+
1403
+
1404
+
1405
+
1406
+ <h4 class="name" id="generateJsonFileFromCsv"><span class="type-signature"></span>generateJsonFileFromCsv<span class="signature">(inputFileName, outputFileName)</span><span class="type-signature"></span></h4>
1407
+
1408
+
1409
+
1410
+
1411
+
1412
+
1413
+ <div class="description">
1414
+ <p>Parse CSV file and write the parsed JSON to an output file (synchronous)</p>
1415
+ </div>
1416
+
1417
+
1418
+
1419
+
1420
+
1421
+
1422
+
1423
+
1424
+
1425
+ <h5>Parameters:</h5>
1426
+
1427
+
1428
+ <table class="params">
1429
+ <thead>
1430
+ <tr>
1431
+
1432
+ <th>Name</th>
1433
+
1434
+
1435
+ <th>Type</th>
1436
+
1437
+
1438
+
1439
+
1440
+
1441
+ <th class="last">Description</th>
1442
+ </tr>
1443
+ </thead>
1444
+
1445
+ <tbody>
1446
+
1447
+
1448
+ <tr>
1449
+
1450
+ <td class="name"><code>inputFileName</code></td>
1451
+
1452
+
1453
+ <td class="type">
1454
+
1455
+
1456
+ <span class="param-type">string</span>
1457
+
1458
+
1459
+
1460
+ </td>
1461
+
1462
+
1463
+
1464
+
1465
+
1466
+ <td class="description last"><p>Path to input CSV file</p></td>
1467
+ </tr>
1468
+
1469
+
1470
+
1471
+ <tr>
1472
+
1473
+ <td class="name"><code>outputFileName</code></td>
1474
+
1475
+
1476
+ <td class="type">
1477
+
1478
+
1479
+ <span class="param-type">string</span>
1480
+
1481
+
1482
+
1483
+ </td>
1484
+
1485
+
1486
+
1487
+
1488
+
1489
+ <td class="description last"><p>Path to output JSON file</p></td>
1490
+ </tr>
1491
+
1492
+
1493
+ </tbody>
1494
+ </table>
1495
+
1496
+
1497
+
1498
+
1499
+
1500
+
1501
+ <dl class="details">
1502
+
1503
+
1504
+
1505
+
1506
+
1507
+
1508
+
1509
+
1510
+
1511
+
1512
+
1513
+
1514
+
1515
+
1516
+
1517
+
1518
+
1519
+
1520
+
1521
+
1522
+
1523
+
1524
+
1525
+
1526
+
1527
+
1528
+ <dt class="tag-source">Source:</dt>
1529
+ <dd class="tag-source"><ul class="dummy"><li>
1530
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line193">line 193</a>
1531
+ </li></ul></dd>
1532
+
1533
+
1534
+
1535
+
1536
+
1537
+
1538
+
1539
+ </dl>
1540
+
1541
+
1542
+
1543
+
1544
+
1545
+
1546
+
1547
+
1548
+
1549
+
1550
+
1551
+
1552
+
1553
+ <h5>Throws:</h5>
1554
+ <ul>
1555
+ <li>
1556
+
1557
+ <dl>
1558
+ <dt>
1559
+ <div class="param-desc">
1560
+ <p>If inputFileName or outputFileName is not defined</p>
1561
+ </div>
1562
+ </dt>
1563
+ <dd></dd>
1564
+ <dt>
1565
+ <dl>
1566
+ <dt>
1567
+ Type
1568
+ </dt>
1569
+ <dd>
1570
+
1571
+ <span class="param-type">Error</span>
1572
+
1573
+
1574
+ </dd>
1575
+ </dl>
1576
+ </dt>
1577
+ <dd></dd>
1578
+ </dl>
1579
+
1580
+ </li>
1581
+
1582
+ <li>
1583
+
1584
+ <dl>
1585
+ <dt>
1586
+ <div class="param-desc">
1587
+ <p>If file operations fail</p>
1588
+ </div>
1589
+ </dt>
1590
+ <dd></dd>
1591
+ <dt>
1592
+ <dl>
1593
+ <dt>
1594
+ Type
1595
+ </dt>
1596
+ <dd>
1597
+
1598
+ <span class="param-type"><a href="FileOperationError.html">FileOperationError</a></span>
1599
+
1600
+
1601
+ </dd>
1602
+ </dl>
1603
+ </dt>
1604
+ <dd></dd>
1605
+ </dl>
1606
+
1607
+ </li>
1608
+
1609
+ <li>
1610
+
1611
+ <dl>
1612
+ <dt>
1613
+ <div class="param-desc">
1614
+ <p>If CSV is malformed</p>
1615
+ </div>
1616
+ </dt>
1617
+ <dd></dd>
1618
+ <dt>
1619
+ <dl>
1620
+ <dt>
1621
+ Type
1622
+ </dt>
1623
+ <dd>
1624
+
1625
+ <span class="param-type"><a href="CsvFormatError.html">CsvFormatError</a></span>
1626
+
1627
+
1628
+ </dd>
1629
+ </dl>
1630
+ </dt>
1631
+ <dd></dd>
1632
+ </dl>
1633
+
1634
+ </li>
1635
+ </ul>
1636
+
1637
+
1638
+
1639
+
1640
+
1641
+
1642
+ <h5>Example</h5>
1643
+
1644
+ <pre class="prettyprint"><code>const csvToJson = require('convert-csv-to-json');
1645
+ csvToJson.generateJsonFileFromCsv('input.csv', 'output.json');</code></pre>
1646
+
1647
+
1648
+
1649
+
1650
+
1651
+
1652
+
1653
+
1654
+
1655
+ <h4 class="name" id="getJsonFromCsv"><span class="type-signature"></span>getJsonFromCsv<span class="signature">(inputFileName)</span><span class="type-signature"> &rarr; {Array.&lt;object>}</span></h4>
1656
+
1657
+
1658
+
1659
+
1660
+
1661
+
1662
+ <div class="description">
1663
+ <p>Parse CSV file and return parsed data as JSON array of objects (synchronous)</p>
1664
+ </div>
1665
+
1666
+
1667
+
1668
+
1669
+
1670
+
1671
+
1672
+
1673
+
1674
+ <h5>Parameters:</h5>
1675
+
1676
+
1677
+ <table class="params">
1678
+ <thead>
1679
+ <tr>
1680
+
1681
+ <th>Name</th>
1682
+
1683
+
1684
+ <th>Type</th>
1685
+
1686
+
1687
+
1688
+
1689
+
1690
+ <th class="last">Description</th>
1691
+ </tr>
1692
+ </thead>
1693
+
1694
+ <tbody>
1695
+
1696
+
1697
+ <tr>
1698
+
1699
+ <td class="name"><code>inputFileName</code></td>
1700
+
1701
+
1702
+ <td class="type">
1703
+
1704
+
1705
+ <span class="param-type">string</span>
1706
+
1707
+
1708
+
1709
+ </td>
1710
+
1711
+
1712
+
1713
+
1714
+
1715
+ <td class="description last"><p>Path to input CSV file</p></td>
1716
+ </tr>
1717
+
1718
+
1719
+ </tbody>
1720
+ </table>
1721
+
1722
+
1723
+
1724
+
1725
+
1726
+
1727
+ <dl class="details">
1728
+
1729
+
1730
+
1731
+
1732
+
1733
+
1734
+
1735
+
1736
+
1737
+
1738
+
1739
+
1740
+
1741
+
1742
+
1743
+
1744
+
1745
+
1746
+
1747
+
1748
+
1749
+
1750
+
1751
+
1752
+
1753
+
1754
+ <dt class="tag-source">Source:</dt>
1755
+ <dd class="tag-source"><ul class="dummy"><li>
1756
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line215">line 215</a>
1757
+ </li></ul></dd>
1758
+
1759
+
1760
+
1761
+
1762
+
1763
+
1764
+
1765
+ </dl>
1766
+
1767
+
1768
+
1769
+
1770
+
1771
+
1772
+
1773
+
1774
+
1775
+
1776
+
1777
+
1778
+
1779
+ <h5>Throws:</h5>
1780
+ <ul>
1781
+ <li>
1782
+
1783
+ <dl>
1784
+ <dt>
1785
+ <div class="param-desc">
1786
+ <p>If inputFileName is not defined</p>
1787
+ </div>
1788
+ </dt>
1789
+ <dd></dd>
1790
+ <dt>
1791
+ <dl>
1792
+ <dt>
1793
+ Type
1794
+ </dt>
1795
+ <dd>
1796
+
1797
+ <span class="param-type">Error</span>
1798
+
1799
+
1800
+ </dd>
1801
+ </dl>
1802
+ </dt>
1803
+ <dd></dd>
1804
+ </dl>
1805
+
1806
+ </li>
1807
+
1808
+ <li>
1809
+
1810
+ <dl>
1811
+ <dt>
1812
+ <div class="param-desc">
1813
+ <p>If file read fails</p>
1814
+ </div>
1815
+ </dt>
1816
+ <dd></dd>
1817
+ <dt>
1818
+ <dl>
1819
+ <dt>
1820
+ Type
1821
+ </dt>
1822
+ <dd>
1823
+
1824
+ <span class="param-type"><a href="FileOperationError.html">FileOperationError</a></span>
1825
+
1826
+
1827
+ </dd>
1828
+ </dl>
1829
+ </dt>
1830
+ <dd></dd>
1831
+ </dl>
1832
+
1833
+ </li>
1834
+
1835
+ <li>
1836
+
1837
+ <dl>
1838
+ <dt>
1839
+ <div class="param-desc">
1840
+ <p>If CSV is malformed</p>
1841
+ </div>
1842
+ </dt>
1843
+ <dd></dd>
1844
+ <dt>
1845
+ <dl>
1846
+ <dt>
1847
+ Type
1848
+ </dt>
1849
+ <dd>
1850
+
1851
+ <span class="param-type"><a href="CsvFormatError.html">CsvFormatError</a></span>
1852
+
1853
+
1854
+ </dd>
1855
+ </dl>
1856
+ </dt>
1857
+ <dd></dd>
1858
+ </dl>
1859
+
1860
+ </li>
1861
+ </ul>
1862
+
1863
+
1864
+ <h5>Returns:</h5>
1865
+
1866
+
1867
+ <div class="param-desc">
1868
+ <p>Array of objects representing CSV rows</p>
1869
+ </div>
1870
+
1871
+
1872
+
1873
+ <dl>
1874
+ <dt>
1875
+ Type
1876
+ </dt>
1877
+ <dd>
1878
+
1879
+ <span class="param-type">Array.&lt;object></span>
1880
+
1881
+
1882
+ </dd>
1883
+ </dl>
1884
+
1885
+
1886
+
1887
+
1888
+
1889
+
1890
+ <h5>Example</h5>
1891
+
1892
+ <pre class="prettyprint"><code>const csvToJson = require('convert-csv-to-json');
1893
+ const rows = csvToJson.getJsonFromCsv('resource/input.csv');
1894
+ console.log(rows);</code></pre>
1895
+
1896
+
1897
+
1898
+
1899
+
1900
+
1901
+
1902
+
1903
+
1904
+ <h4 class="name" id="hexEncoding"><span class="type-signature"></span>hexEncoding<span class="signature">()</span><span class="type-signature"> &rarr; {object}</span></h4>
1905
+
1906
+
1907
+
1908
+
1909
+
1910
+
1911
+ <div class="description">
1912
+ <p>Set Hex encoding for reading files</p>
1913
+ </div>
1914
+
1915
+
1916
+
1917
+
1918
+
1919
+
1920
+
1921
+
1922
+
1923
+
1924
+
1925
+
1926
+
1927
+ <dl class="details">
1928
+
1929
+
1930
+
1931
+
1932
+
1933
+
1934
+
1935
+
1936
+
1937
+
1938
+
1939
+
1940
+
1941
+
1942
+
1943
+
1944
+
1945
+
1946
+
1947
+
1948
+
1949
+
1950
+
1951
+
1952
+
1953
+
1954
+ <dt class="tag-source">Source:</dt>
1955
+ <dd class="tag-source"><ul class="dummy"><li>
1956
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line161">line 161</a>
1957
+ </li></ul></dd>
1958
+
1959
+
1960
+
1961
+
1962
+
1963
+
1964
+
1965
+ </dl>
1966
+
1967
+
1968
+
1969
+
1970
+
1971
+
1972
+
1973
+
1974
+
1975
+
1976
+
1977
+
1978
+
1979
+
1980
+
1981
+ <h5>Returns:</h5>
1982
+
1983
+
1984
+ <div class="param-desc">
1985
+ <p>Module context for method chaining</p>
1986
+ </div>
1987
+
1988
+
1989
+
1990
+ <dl>
1991
+ <dt>
1992
+ Type
1993
+ </dt>
1994
+ <dd>
1995
+
1996
+ <span class="param-type">object</span>
1997
+
1998
+
1999
+ </dd>
2000
+ </dl>
2001
+
2002
+
2003
+
2004
+
2005
+
2006
+
2007
+
2008
+
2009
+
2010
+
2011
+
2012
+
2013
+
2014
+ <h4 class="name" id="indexHeader"><span class="type-signature"></span>indexHeader<span class="signature">(index)</span><span class="type-signature"> &rarr; {object}</span></h4>
2015
+
2016
+
2017
+
2018
+
2019
+
2020
+
2021
+ <div class="description">
2022
+ <p>Set the row index where CSV headers are located
2023
+ Use this if headers are not on the first line (row 0)</p>
2024
+ </div>
2025
+
2026
+
2027
+
2028
+
2029
+
2030
+
2031
+
2032
+
2033
+
2034
+ <h5>Parameters:</h5>
2035
+
2036
+
2037
+ <table class="params">
2038
+ <thead>
2039
+ <tr>
2040
+
2041
+ <th>Name</th>
2042
+
2043
+
2044
+ <th>Type</th>
2045
+
2046
+
2047
+
2048
+
2049
+
2050
+ <th class="last">Description</th>
2051
+ </tr>
2052
+ </thead>
2053
+
2054
+ <tbody>
2055
+
2056
+
2057
+ <tr>
2058
+
2059
+ <td class="name"><code>index</code></td>
2060
+
2061
+
2062
+ <td class="type">
2063
+
2064
+
2065
+ <span class="param-type">number</span>
2066
+
2067
+
2068
+
2069
+ </td>
2070
+
2071
+
2072
+
2073
+
2074
+
2075
+ <td class="description last"><p>Zero-based row index containing headers</p></td>
2076
+ </tr>
2077
+
2078
+
2079
+ </tbody>
2080
+ </table>
2081
+
2082
+
2083
+
2084
+
2085
+
2086
+
2087
+ <dl class="details">
2088
+
2089
+
2090
+
2091
+
2092
+
2093
+
2094
+
2095
+
2096
+
2097
+
2098
+
2099
+
2100
+
2101
+
2102
+
2103
+
2104
+
2105
+
2106
+
2107
+
2108
+
2109
+
2110
+
2111
+
2112
+
2113
+
2114
+ <dt class="tag-source">Source:</dt>
2115
+ <dd class="tag-source"><ul class="dummy"><li>
2116
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line71">line 71</a>
2117
+ </li></ul></dd>
2118
+
2119
+
2120
+
2121
+
2122
+
2123
+
2124
+
2125
+ </dl>
2126
+
2127
+
2128
+
2129
+
2130
+
2131
+
2132
+
2133
+
2134
+
2135
+
2136
+
2137
+
2138
+
2139
+
2140
+
2141
+ <h5>Returns:</h5>
2142
+
2143
+
2144
+ <div class="param-desc">
2145
+ <p>Module context for method chaining</p>
2146
+ </div>
2147
+
2148
+
2149
+
2150
+ <dl>
2151
+ <dt>
2152
+ Type
2153
+ </dt>
2154
+ <dd>
2155
+
2156
+ <span class="param-type">object</span>
2157
+
2158
+
2159
+ </dd>
2160
+ </dl>
2161
+
2162
+
2163
+
2164
+
2165
+
2166
+
2167
+
2168
+
2169
+
2170
+
2171
+
2172
+
2173
+
2174
+ <h4 class="name" id="latin1Encoding"><span class="type-signature"></span>latin1Encoding<span class="signature">()</span><span class="type-signature"> &rarr; {object}</span></h4>
2175
+
2176
+
2177
+
2178
+
2179
+
2180
+
2181
+ <div class="description">
2182
+ <p>Set Latin-1 (ISO-8859-1) encoding for reading files</p>
2183
+ </div>
2184
+
2185
+
2186
+
2187
+
2188
+
2189
+
2190
+
2191
+
2192
+
2193
+
2194
+
2195
+
2196
+
2197
+ <dl class="details">
2198
+
2199
+
2200
+
2201
+
2202
+
2203
+
2204
+
2205
+
2206
+
2207
+
2208
+
2209
+
2210
+
2211
+
2212
+
2213
+
2214
+
2215
+
2216
+
2217
+
2218
+
2219
+
2220
+
2221
+
2222
+
2223
+
2224
+ <dt class="tag-source">Source:</dt>
2225
+ <dd class="tag-source"><ul class="dummy"><li>
2226
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line134">line 134</a>
2227
+ </li></ul></dd>
2228
+
2229
+
2230
+
2231
+
2232
+
2233
+
2234
+
2235
+ </dl>
2236
+
2237
+
2238
+
2239
+
2240
+
2241
+
2242
+
2243
+
2244
+
2245
+
2246
+
2247
+
2248
+
2249
+
2250
+
2251
+ <h5>Returns:</h5>
2252
+
2253
+
2254
+ <div class="param-desc">
2255
+ <p>Module context for method chaining</p>
2256
+ </div>
2257
+
2258
+
2259
+
2260
+ <dl>
2261
+ <dt>
2262
+ Type
2263
+ </dt>
2264
+ <dd>
2265
+
2266
+ <span class="param-type">object</span>
2267
+
2268
+
2269
+ </dd>
2270
+ </dl>
2271
+
2272
+
2273
+
2274
+
2275
+
2276
+
2277
+
2278
+
2279
+
2280
+
2281
+
2282
+
2283
+
2284
+ <h4 class="name" id="mapRows"><span class="type-signature"></span>mapRows<span class="signature">(mapperFn)</span><span class="type-signature"> &rarr; {object}</span></h4>
2285
+
2286
+
2287
+
2288
+
2289
+
2290
+
2291
+ <div class="description">
2292
+ <p>Set a mapper function to transform each row after conversion
2293
+ The mapper function receives (row, index) where row is the JSON object
2294
+ and index is the 0-based row number. Return null/undefined to filter out rows.</p>
2295
+ </div>
2296
+
2297
+
2298
+
2299
+
2300
+
2301
+
2302
+
2303
+
2304
+
2305
+ <h5>Parameters:</h5>
2306
+
2307
+
2308
+ <table class="params">
2309
+ <thead>
2310
+ <tr>
2311
+
2312
+ <th>Name</th>
2313
+
2314
+
2315
+ <th>Type</th>
2316
+
2317
+
2318
+
2319
+
2320
+
2321
+ <th class="last">Description</th>
2322
+ </tr>
2323
+ </thead>
2324
+
2325
+ <tbody>
2326
+
2327
+
2328
+ <tr>
2329
+
2330
+ <td class="name"><code>mapperFn</code></td>
2331
+
2332
+
2333
+ <td class="type">
2334
+
2335
+
2336
+ <span class="param-type">function</span>
2337
+
2338
+
2339
+
2340
+ </td>
2341
+
2342
+
2343
+
2344
+
2345
+
2346
+ <td class="description last"><p>Function to transform each row: <code>(row, index) =&gt; transformedRow | null</code></p></td>
2347
+ </tr>
2348
+
2349
+
2350
+ </tbody>
2351
+ </table>
2352
+
2353
+
2354
+
2355
+
2356
+
2357
+
2358
+ <dl class="details">
2359
+
2360
+
2361
+
2362
+
2363
+
2364
+
2365
+
2366
+
2367
+
2368
+
2369
+
2370
+
2371
+
2372
+
2373
+
2374
+
2375
+
2376
+
2377
+
2378
+
2379
+
2380
+
2381
+
2382
+
2383
+
2384
+
2385
+ <dt class="tag-source">Source:</dt>
2386
+ <dd class="tag-source"><ul class="dummy"><li>
2387
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line177">line 177</a>
2388
+ </li></ul></dd>
2389
+
2390
+
2391
+
2392
+
2393
+
2394
+
2395
+
2396
+ </dl>
2397
+
2398
+
2399
+
2400
+
2401
+
2402
+
2403
+
2404
+
2405
+
2406
+
2407
+
2408
+
2409
+
2410
+
2411
+
2412
+ <h5>Returns:</h5>
2413
+
2414
+
2415
+ <div class="param-desc">
2416
+ <p>Module context for method chaining</p>
2417
+ </div>
2418
+
2419
+
2420
+
2421
+ <dl>
2422
+ <dt>
2423
+ Type
2424
+ </dt>
2425
+ <dd>
2426
+
2427
+ <span class="param-type">object</span>
2428
+
2429
+
2430
+ </dd>
2431
+ </dl>
2432
+
2433
+
2434
+
2435
+
2436
+
2437
+
2438
+ <h5>Example</h5>
2439
+
2440
+ <pre class="prettyprint"><code>csvToJson
2441
+ .mapRows((row, idx) => idx % 2 === 0 ? row : null) // Keep every other row
2442
+ .getJsonFromCsv('input.csv')</code></pre>
2443
+
2444
+
2445
+
2446
+
2447
+
2448
+
2449
+
2450
+
2451
+
2452
+ <h4 class="name" id="parseSubArray"><span class="type-signature"></span>parseSubArray<span class="signature">(delimiter, separator)</span><span class="type-signature"> &rarr; {object}</span></h4>
2453
+
2454
+
2455
+
2456
+
2457
+
2458
+
2459
+ <div class="description">
2460
+ <p>Configure sub-array parsing for special field values
2461
+ Fields bracketed by delimiter and containing separator are parsed into arrays</p>
2462
+ </div>
2463
+
2464
+
2465
+
2466
+
2467
+
2468
+
2469
+
2470
+
2471
+
2472
+ <h5>Parameters:</h5>
2473
+
2474
+
2475
+ <table class="params">
2476
+ <thead>
2477
+ <tr>
2478
+
2479
+ <th>Name</th>
2480
+
2481
+
2482
+ <th>Type</th>
2483
+
2484
+
2485
+
2486
+
2487
+
2488
+ <th class="last">Description</th>
2489
+ </tr>
2490
+ </thead>
2491
+
2492
+ <tbody>
2493
+
2494
+
2495
+ <tr>
2496
+
2497
+ <td class="name"><code>delimiter</code></td>
2498
+
2499
+
2500
+ <td class="type">
2501
+
2502
+
2503
+ <span class="param-type">string</span>
2504
+
2505
+
2506
+
2507
+ </td>
2508
+
2509
+
2510
+
2511
+
2512
+
2513
+ <td class="description last"><p>Bracket character (default: '*')</p></td>
2514
+ </tr>
2515
+
2516
+
2517
+
2518
+ <tr>
2519
+
2520
+ <td class="name"><code>separator</code></td>
2521
+
2522
+
2523
+ <td class="type">
2524
+
2525
+
2526
+ <span class="param-type">string</span>
2527
+
2528
+
2529
+
2530
+ </td>
2531
+
2532
+
2533
+
2534
+
2535
+
2536
+ <td class="description last"><p>Item separator within brackets (default: ',')</p></td>
2537
+ </tr>
2538
+
2539
+
2540
+ </tbody>
2541
+ </table>
2542
+
2543
+
2544
+
2545
+
2546
+
2547
+
2548
+ <dl class="details">
2549
+
2550
+
2551
+
2552
+
2553
+
2554
+
2555
+
2556
+
2557
+
2558
+
2559
+
2560
+
2561
+
2562
+
2563
+
2564
+
2565
+
2566
+
2567
+
2568
+
2569
+
2570
+
2571
+
2572
+
2573
+
2574
+
2575
+ <dt class="tag-source">Source:</dt>
2576
+ <dd class="tag-source"><ul class="dummy"><li>
2577
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line87">line 87</a>
2578
+ </li></ul></dd>
2579
+
2580
+
2581
+
2582
+
2583
+
2584
+
2585
+
2586
+ </dl>
2587
+
2588
+
2589
+
2590
+
2591
+
2592
+
2593
+
2594
+
2595
+
2596
+
2597
+
2598
+
2599
+
2600
+
2601
+
2602
+ <h5>Returns:</h5>
2603
+
2604
+
2605
+ <div class="param-desc">
2606
+ <p>Module context for method chaining</p>
2607
+ </div>
2608
+
2609
+
2610
+
2611
+ <dl>
2612
+ <dt>
2613
+ Type
2614
+ </dt>
2615
+ <dd>
2616
+
2617
+ <span class="param-type">object</span>
2618
+
2619
+
2620
+ </dd>
2621
+ </dl>
2622
+
2623
+
2624
+
2625
+
2626
+
2627
+
2628
+ <h5>Example</h5>
2629
+
2630
+ <pre class="prettyprint"><code>// Input field: "*val1,val2,val3*"
2631
+ // Output array: ["val1", "val2", "val3"]
2632
+ csvToJson.parseSubArray('*', ',')</code></pre>
2633
+
2634
+
2635
+
2636
+
2637
+
2638
+
2639
+
2640
+
2641
+
2642
+ <h4 class="name" id="supportQuotedField"><span class="type-signature"></span>supportQuotedField<span class="signature">(active)</span><span class="type-signature"> &rarr; {object}</span></h4>
2643
+
2644
+
2645
+
2646
+
2647
+
2648
+
2649
+ <div class="description">
2650
+ <p>Enable or disable support for RFC 4180 quoted fields
2651
+ When enabled, fields wrapped in double quotes can contain delimiters and newlines</p>
2652
+ </div>
2653
+
2654
+
2655
+
2656
+
2657
+
2658
+
2659
+
2660
+
2661
+
2662
+ <h5>Parameters:</h5>
2663
+
2664
+
2665
+ <table class="params">
2666
+ <thead>
2667
+ <tr>
2668
+
2669
+ <th>Name</th>
2670
+
2671
+
2672
+ <th>Type</th>
2673
+
2674
+
2675
+
2676
+
2677
+
2678
+ <th class="last">Description</th>
2679
+ </tr>
2680
+ </thead>
2681
+
2682
+ <tbody>
2683
+
2684
+
2685
+ <tr>
2686
+
2687
+ <td class="name"><code>active</code></td>
2688
+
2689
+
2690
+ <td class="type">
2691
+
2692
+
2693
+ <span class="param-type">boolean</span>
2694
+
2695
+
2696
+
2697
+ </td>
2698
+
2699
+
2700
+
2701
+
2702
+
2703
+ <td class="description last"><p>Whether to support quoted fields (default: false)</p></td>
2704
+ </tr>
2705
+
2706
+
2707
+ </tbody>
2708
+ </table>
2709
+
2710
+
2711
+
2712
+
2713
+
2714
+
2715
+ <dl class="details">
2716
+
2717
+
2718
+
2719
+
2720
+
2721
+
2722
+
2723
+
2724
+
2725
+
2726
+
2727
+
2728
+
2729
+
2730
+
2731
+
2732
+
2733
+
2734
+
2735
+
2736
+
2737
+
2738
+
2739
+
2740
+
2741
+
2742
+ <dt class="tag-source">Source:</dt>
2743
+ <dd class="tag-source"><ul class="dummy"><li>
2744
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line39">line 39</a>
2745
+ </li></ul></dd>
2746
+
2747
+
2748
+
2749
+
2750
+
2751
+
2752
+
2753
+ </dl>
2754
+
2755
+
2756
+
2757
+
2758
+
2759
+
2760
+
2761
+
2762
+
2763
+
2764
+
2765
+
2766
+
2767
+
2768
+
2769
+ <h5>Returns:</h5>
2770
+
2771
+
2772
+ <div class="param-desc">
2773
+ <p>Module context for method chaining</p>
2774
+ </div>
2775
+
2776
+
2777
+
2778
+ <dl>
2779
+ <dt>
2780
+ Type
2781
+ </dt>
2782
+ <dd>
2783
+
2784
+ <span class="param-type">object</span>
2785
+
2786
+
2787
+ </dd>
2788
+ </dl>
2789
+
2790
+
2791
+
2792
+
2793
+
2794
+
2795
+
2796
+
2797
+
2798
+
2799
+
2800
+
2801
+
2802
+ <h4 class="name" id="trimHeaderFieldWhiteSpace"><span class="type-signature"></span>trimHeaderFieldWhiteSpace<span class="signature">(active)</span><span class="type-signature"> &rarr; {object}</span></h4>
2803
+
2804
+
2805
+
2806
+
2807
+
2808
+
2809
+ <div class="description">
2810
+ <p>Configure whitespace handling in CSV header field names
2811
+ When active, removes all whitespace from header names (e.g., &quot;My Name&quot; → &quot;MyName&quot;)
2812
+ When inactive, only trims leading and trailing whitespace</p>
2813
+ </div>
2814
+
2815
+
2816
+
2817
+
2818
+
2819
+
2820
+
2821
+
2822
+
2823
+ <h5>Parameters:</h5>
2824
+
2825
+
2826
+ <table class="params">
2827
+ <thead>
2828
+ <tr>
2829
+
2830
+ <th>Name</th>
2831
+
2832
+
2833
+ <th>Type</th>
2834
+
2835
+
2836
+
2837
+
2838
+
2839
+ <th class="last">Description</th>
2840
+ </tr>
2841
+ </thead>
2842
+
2843
+ <tbody>
2844
+
2845
+
2846
+ <tr>
2847
+
2848
+ <td class="name"><code>active</code></td>
2849
+
2850
+
2851
+ <td class="type">
2852
+
2853
+
2854
+ <span class="param-type">boolean</span>
2855
+
2856
+
2857
+
2858
+ </td>
2859
+
2860
+
2861
+
2862
+
2863
+
2864
+ <td class="description last"><p>Whether to remove all whitespace from headers (default: false)</p></td>
2865
+ </tr>
2866
+
2867
+
2868
+ </tbody>
2869
+ </table>
2870
+
2871
+
2872
+
2873
+
2874
+
2875
+
2876
+ <dl class="details">
2877
+
2878
+
2879
+
2880
+
2881
+
2882
+
2883
+
2884
+
2885
+
2886
+
2887
+
2888
+
2889
+
2890
+
2891
+
2892
+
2893
+
2894
+
2895
+
2896
+
2897
+
2898
+
2899
+
2900
+
2901
+
2902
+
2903
+ <dt class="tag-source">Source:</dt>
2904
+ <dd class="tag-source"><ul class="dummy"><li>
2905
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line60">line 60</a>
2906
+ </li></ul></dd>
2907
+
2908
+
2909
+
2910
+
2911
+
2912
+
2913
+
2914
+ </dl>
2915
+
2916
+
2917
+
2918
+
2919
+
2920
+
2921
+
2922
+
2923
+
2924
+
2925
+
2926
+
2927
+
2928
+
2929
+
2930
+ <h5>Returns:</h5>
2931
+
2932
+
2933
+ <div class="param-desc">
2934
+ <p>Module context for method chaining</p>
2935
+ </div>
2936
+
2937
+
2938
+
2939
+ <dl>
2940
+ <dt>
2941
+ Type
2942
+ </dt>
2943
+ <dd>
2944
+
2945
+ <span class="param-type">object</span>
2946
+
2947
+
2948
+ </dd>
2949
+ </dl>
2950
+
2951
+
2952
+
2953
+
2954
+
2955
+
2956
+
2957
+
2958
+
2959
+
2960
+
2961
+
2962
+
2963
+ <h4 class="name" id="ucs2Encoding"><span class="type-signature"></span>ucs2Encoding<span class="signature">()</span><span class="type-signature"> &rarr; {object}</span></h4>
2964
+
2965
+
2966
+
2967
+
2968
+
2969
+
2970
+ <div class="description">
2971
+ <p>Set UCS-2 encoding for reading files</p>
2972
+ </div>
2973
+
2974
+
2975
+
2976
+
2977
+
2978
+
2979
+
2980
+
2981
+
2982
+
2983
+
2984
+
2985
+
2986
+ <dl class="details">
2987
+
2988
+
2989
+
2990
+
2991
+
2992
+
2993
+
2994
+
2995
+
2996
+
2997
+
2998
+
2999
+
3000
+
3001
+
3002
+
3003
+
3004
+
3005
+
3006
+
3007
+
3008
+
3009
+
3010
+
3011
+
3012
+
3013
+ <dt class="tag-source">Source:</dt>
3014
+ <dd class="tag-source"><ul class="dummy"><li>
3015
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line116">line 116</a>
3016
+ </li></ul></dd>
3017
+
3018
+
3019
+
3020
+
3021
+
3022
+
3023
+
3024
+ </dl>
3025
+
3026
+
3027
+
3028
+
3029
+
3030
+
3031
+
3032
+
3033
+
3034
+
3035
+
3036
+
3037
+
3038
+
3039
+
3040
+ <h5>Returns:</h5>
3041
+
3042
+
3043
+ <div class="param-desc">
3044
+ <p>Module context for method chaining</p>
3045
+ </div>
3046
+
3047
+
3048
+
3049
+ <dl>
3050
+ <dt>
3051
+ Type
3052
+ </dt>
3053
+ <dd>
3054
+
3055
+ <span class="param-type">object</span>
3056
+
3057
+
3058
+ </dd>
3059
+ </dl>
3060
+
3061
+
3062
+
3063
+
3064
+
3065
+
3066
+
3067
+
3068
+
3069
+
3070
+
3071
+
3072
+
3073
+ <h4 class="name" id="utf16leEncoding"><span class="type-signature"></span>utf16leEncoding<span class="signature">()</span><span class="type-signature"> &rarr; {object}</span></h4>
3074
+
3075
+
3076
+
3077
+
3078
+
3079
+
3080
+ <div class="description">
3081
+ <p>Set UTF-16 LE encoding for reading files</p>
3082
+ </div>
3083
+
3084
+
3085
+
3086
+
3087
+
3088
+
3089
+
3090
+
3091
+
3092
+
3093
+
3094
+
3095
+
3096
+ <dl class="details">
3097
+
3098
+
3099
+
3100
+
3101
+
3102
+
3103
+
3104
+
3105
+
3106
+
3107
+
3108
+
3109
+
3110
+
3111
+
3112
+
3113
+
3114
+
3115
+
3116
+
3117
+
3118
+
3119
+
3120
+
3121
+
3122
+
3123
+ <dt class="tag-source">Source:</dt>
3124
+ <dd class="tag-source"><ul class="dummy"><li>
3125
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line125">line 125</a>
3126
+ </li></ul></dd>
3127
+
3128
+
3129
+
3130
+
3131
+
3132
+
3133
+
3134
+ </dl>
3135
+
3136
+
3137
+
3138
+
3139
+
3140
+
3141
+
3142
+
3143
+
3144
+
3145
+
3146
+
3147
+
3148
+
3149
+
3150
+ <h5>Returns:</h5>
3151
+
3152
+
3153
+ <div class="param-desc">
3154
+ <p>Module context for method chaining</p>
3155
+ </div>
3156
+
3157
+
3158
+
3159
+ <dl>
3160
+ <dt>
3161
+ Type
3162
+ </dt>
3163
+ <dd>
3164
+
3165
+ <span class="param-type">object</span>
3166
+
3167
+
3168
+ </dd>
3169
+ </dl>
3170
+
3171
+
3172
+
3173
+
3174
+
3175
+
3176
+
3177
+
3178
+
3179
+
3180
+
3181
+
3182
+
3183
+ <h4 class="name" id="utf8Encoding"><span class="type-signature"></span>utf8Encoding<span class="signature">()</span><span class="type-signature"> &rarr; {object}</span></h4>
3184
+
3185
+
3186
+
3187
+
3188
+
3189
+
3190
+ <div class="description">
3191
+ <p>Set UTF-8 encoding (default encoding)</p>
3192
+ </div>
3193
+
3194
+
3195
+
3196
+
3197
+
3198
+
3199
+
3200
+
3201
+
3202
+
3203
+
3204
+
3205
+
3206
+ <dl class="details">
3207
+
3208
+
3209
+
3210
+
3211
+
3212
+
3213
+
3214
+
3215
+
3216
+
3217
+
3218
+
3219
+
3220
+
3221
+
3222
+
3223
+
3224
+
3225
+
3226
+
3227
+
3228
+
3229
+
3230
+
3231
+
3232
+
3233
+ <dt class="tag-source">Source:</dt>
3234
+ <dd class="tag-source"><ul class="dummy"><li>
3235
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line107">line 107</a>
3236
+ </li></ul></dd>
3237
+
3238
+
3239
+
3240
+
3241
+
3242
+
3243
+
3244
+ </dl>
3245
+
3246
+
3247
+
3248
+
3249
+
3250
+
3251
+
3252
+
3253
+
3254
+
3255
+
3256
+
3257
+
3258
+
3259
+
3260
+ <h5>Returns:</h5>
3261
+
3262
+
3263
+ <div class="param-desc">
3264
+ <p>Module context for method chaining</p>
3265
+ </div>
3266
+
3267
+
3268
+
3269
+ <dl>
3270
+ <dt>
3271
+ Type
3272
+ </dt>
3273
+ <dd>
3274
+
3275
+ <span class="param-type">object</span>
3276
+
3277
+
3278
+ </dd>
3279
+ </dl>
3280
+
3281
+
3282
+
3283
+
3284
+
3285
+
3286
+
3287
+
3288
+
3289
+
3290
+
3291
+
3292
+
3293
+ </article>
3294
+
3295
+ </section>
3296
+
3297
+
3298
+
3299
+
3300
+ </div>
3301
+
3302
+ <nav>
3303
+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BrowserApi.html">BrowserApi</a></li><li><a href="BrowserApiError.html">BrowserApiError</a></li><li><a href="ConfigurationError.html">ConfigurationError</a></li><li><a href="CsvFormatError.html">CsvFormatError</a></li><li><a href="CsvParsingError.html">CsvParsingError</a></li><li><a href="CsvToJson.html">CsvToJson</a></li><li><a href="CsvToJsonAsync.html">CsvToJsonAsync</a></li><li><a href="FileOperationError.html">FileOperationError</a></li><li><a href="FileUtils.html">FileUtils</a></li><li><a href="InputValidationError.html">InputValidationError</a></li><li><a href="JsonUtil.html">JsonUtil</a></li><li><a href="JsonValidationError.html">JsonValidationError</a></li></ul><h3>Global</h3><ul><li><a href="global.html#asciiEncoding">asciiEncoding</a></li><li><a href="global.html#base64Encoding">base64Encoding</a></li><li><a href="global.html#browser">browser</a></li><li><a href="global.html#csvStringToJson">csvStringToJson</a></li><li><a href="global.html#csvStringToJsonStringified">csvStringToJsonStringified</a></li><li><a href="global.html#csvToJsonAsync">csvToJsonAsync</a></li><li><a href="global.html#customEncoding">customEncoding</a></li><li><a href="global.html#fieldDelimiter">fieldDelimiter</a></li><li><a href="global.html#formatValueByType">formatValueByType</a></li><li><a href="global.html#generateJsonFileFromCsv">generateJsonFileFromCsv</a></li><li><a href="global.html#getJsonFromCsv">getJsonFromCsv</a></li><li><a href="global.html#hexEncoding">hexEncoding</a></li><li><a href="global.html#indexHeader">indexHeader</a></li><li><a href="global.html#latin1Encoding">latin1Encoding</a></li><li><a href="global.html#mapRows">mapRows</a></li><li><a href="global.html#parseSubArray">parseSubArray</a></li><li><a href="global.html#supportQuotedField">supportQuotedField</a></li><li><a href="global.html#trimHeaderFieldWhiteSpace">trimHeaderFieldWhiteSpace</a></li><li><a href="global.html#ucs2Encoding">ucs2Encoding</a></li><li><a href="global.html#utf16leEncoding">utf16leEncoding</a></li><li><a href="global.html#utf8Encoding">utf8Encoding</a></li></ul>
3304
+ </nav>
3305
+
3306
+ <br class="clear">
3307
+
3308
+ <footer>
3309
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a> on Fri Mar 20 2026 14:48:29 GMT+0000 (Coordinated Universal Time)
3310
+ </footer>
3311
+
3312
+ <script> prettyPrint(); </script>
3313
+ <script src="scripts/linenumber.js"> </script>
3314
+ </body>
3315
+ </html>