select-csv 1.1.22 → 1.1.24
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.
- package/README.md +15 -11
- package/package.json +1 -1
- package/test.js +28 -0
package/README.md
CHANGED
|
@@ -51,7 +51,11 @@ parse = parseText(
|
|
|
51
51
|
7,FCdfFf08196f633,Collin,Allison,Male
|
|
52
52
|
8,356279dAa0F7CbD,Nicholas,Branch,Male
|
|
53
53
|
9,F563CcbFBfEcf5a,Emma,Robinson,Female
|
|
54
|
-
10,f2dceFc00F62542,Pedro,Cordova,Male
|
|
54
|
+
10,f2dceFc00F62542,Pedro,Cordova,Male`,
|
|
55
|
+
{
|
|
56
|
+
linebreak: '\n',
|
|
57
|
+
header: true
|
|
58
|
+
}
|
|
55
59
|
);
|
|
56
60
|
|
|
57
61
|
|
|
@@ -62,7 +66,7 @@ parse = parseText(
|
|
|
62
66
|
const result = parse.get(); //Return all rows
|
|
63
67
|
/*
|
|
64
68
|
{
|
|
65
|
-
|
|
69
|
+
Time: "0 ms",
|
|
66
70
|
header:["Index","User Id","First Name","Last Name","Sex"],
|
|
67
71
|
rows:[
|
|
68
72
|
["1","5f10e9D33fC5f2b","Sara","Mcguire","Female"],
|
|
@@ -93,7 +97,7 @@ result = parse.chunk(c)
|
|
|
93
97
|
result = parse.chunk(2) //Return row 0 and 1
|
|
94
98
|
/*
|
|
95
99
|
{
|
|
96
|
-
|
|
100
|
+
Time: "0 ms",
|
|
97
101
|
"Header": [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
|
|
98
102
|
"Rows": [
|
|
99
103
|
[ "1", "5f10e9D33fC5f2b", "Sara", "Mcguire", "Female" ],
|
|
@@ -106,7 +110,7 @@ result = parse.chunk(2) //Return row 0 and 1
|
|
|
106
110
|
result = parse.chunk(3) //Return row 2,3 and 4 (Get rows from last offset saved)
|
|
107
111
|
/*
|
|
108
112
|
{
|
|
109
|
-
|
|
113
|
+
Time: "0 ms",
|
|
110
114
|
"Header": [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
|
|
111
115
|
"Rows": [
|
|
112
116
|
[ "3", "DcEFDB2D2e62bF9", "Gwendolyn", "Sheppard", "Male" ],
|
|
@@ -120,7 +124,7 @@ result = parse.chunk(3) //Return row 2,3 and 4 (Get rows from last offset saved)
|
|
|
120
124
|
result = parse.chunk(1) //Return row 5 (Get rows from last offset saved)
|
|
121
125
|
/*
|
|
122
126
|
{
|
|
123
|
-
|
|
127
|
+
Time: "0 ms",
|
|
124
128
|
"Header": [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
|
|
125
129
|
"Rows": [
|
|
126
130
|
[ "6", "BdDb6C8Af309202", "Calvin", "Ramsey", "Female" ]
|
|
@@ -147,7 +151,7 @@ result = parse.rowOffset(from,to)
|
|
|
147
151
|
result = parse.rowOffset(6) //Returns all rows from the sixth row to the last row
|
|
148
152
|
/*
|
|
149
153
|
{
|
|
150
|
-
|
|
154
|
+
Time: "0 ms",
|
|
151
155
|
"Header": [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
|
|
152
156
|
"Rows": [
|
|
153
157
|
[ "7", "FCdfFf08196f633", "Collin", "Allison", "Male" ],
|
|
@@ -162,7 +166,7 @@ result = parse.rowOffset(6) //Returns all rows from the sixth row to the last ro
|
|
|
162
166
|
result = parse.rowOffset(5,8) //Returns all rows from 5th to 8th row
|
|
163
167
|
/*
|
|
164
168
|
{
|
|
165
|
-
|
|
169
|
+
Time: "1 ms",
|
|
166
170
|
"Header": [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
|
|
167
171
|
"Rows": [
|
|
168
172
|
[ "6", "BdDb6C8Af309202", "Calvin", "Ramsey", "Female" ],
|
|
@@ -192,7 +196,7 @@ result = parse.setRowOffset(5)
|
|
|
192
196
|
result = parse.chunk(1) // Get rows from last offset saved
|
|
193
197
|
/*
|
|
194
198
|
{
|
|
195
|
-
|
|
199
|
+
Time: "0 ms",
|
|
196
200
|
"Header": [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
|
|
197
201
|
"Rows": [
|
|
198
202
|
[ "6", "BdDb6C8Af309202", "Calvin", "Ramsey", "Female" ]
|
|
@@ -209,7 +213,7 @@ false
|
|
|
209
213
|
result = parse.chunk(1) // Get rows from last offset saved
|
|
210
214
|
/*
|
|
211
215
|
{
|
|
212
|
-
|
|
216
|
+
Time: "0 ms",
|
|
213
217
|
"Header": [ "Index", "User Id", "First Name", "Last Name", "Sex" ],
|
|
214
218
|
"Rows": [
|
|
215
219
|
[ "7", "FCdfFf08196f633", "Collin", "Allison", "Male" ]
|
|
@@ -264,7 +268,7 @@ option = {
|
|
|
264
268
|
result = parse.rowOffset(2)
|
|
265
269
|
/*
|
|
266
270
|
{
|
|
267
|
-
|
|
271
|
+
Time: "0 ms",
|
|
268
272
|
"Header": false,
|
|
269
273
|
"Rows": [
|
|
270
274
|
[ "2", "751cD1cbF77e005", "Alisha", "Hebert", "Male" ]
|
|
@@ -280,7 +284,7 @@ option = {
|
|
|
280
284
|
// delimiter: (String: get rows containing columns, false: get lines without columns)
|
|
281
285
|
/*
|
|
282
286
|
{
|
|
283
|
-
|
|
287
|
+
Time: "0 ms",
|
|
284
288
|
"Header": false,
|
|
285
289
|
"Rows": [
|
|
286
290
|
[ "2,751cD1cbF77e005,Alisha,Hebert,Male" ] // No columns, just string (all line)
|
package/package.json
CHANGED
package/test.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const {parseCsv,parseText} = require("select-csv");
|
|
2
|
+
|
|
3
|
+
var parse;
|
|
4
|
+
|
|
5
|
+
// First create object from .csv file
|
|
6
|
+
//parse = parseCsv('file_path.csv');
|
|
7
|
+
|
|
8
|
+
// Or if you just want create object from text
|
|
9
|
+
parse = parseText(
|
|
10
|
+
`Index,User Id,First Name,Last Name,Sex
|
|
11
|
+
1,5f10e9D33fC5f2b,Sara,Mcguire,Female
|
|
12
|
+
2,751cD1cbF77e005,Alisha,Hebert,Male
|
|
13
|
+
3,DcEFDB2D2e62bF9,Gwendolyn,Sheppard,Male
|
|
14
|
+
4,C88661E02EEDA9e,Kristine,Mccann,Female
|
|
15
|
+
5,fafF1aBDebaB2a6,Bobby,Pittman,Female
|
|
16
|
+
6,BdDb6C8Af309202,Calvin,Ramsey,Female
|
|
17
|
+
7,FCdfFf08196f633,Collin,Allison,Male
|
|
18
|
+
8,356279dAa0F7CbD,Nicholas,Branch,Male
|
|
19
|
+
9,F563CcbFBfEcf5a,Emma,Robinson,Female
|
|
20
|
+
10,f2dceFc00F62542,Pedro,Cordova,Male`,
|
|
21
|
+
{
|
|
22
|
+
linebreak: '\n',
|
|
23
|
+
header: true
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const result = parse.get();
|
|
28
|
+
console.log(result)
|