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