Skip to content

Commit 6eed22a

Browse files
committed
docs(csv-parse): to sample
1 parent 4ec9e58 commit 6eed22a

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

packages/csv-parse/samples/option.from.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,21 @@ import assert from 'assert';
33
import { parse } from 'csv-parse';
44

55
parse(`
6-
a,b|1,2|3,4
6+
a,b
7+
1,2
8+
3,4
9+
5,6
710
`.trim(), {
811
columns: true,
9-
record_delimiter: '|',
1012
from: 2
1113
}, function(err, records){
1214
assert.deepStrictEqual(
1315
records, [{
1416
a: '3',
1517
b: '4'
18+
}, {
19+
a: '5',
20+
b: '6'
1621
}]
1722
);
1823
});
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
import assert from 'assert';
3+
import { parse } from 'csv-parse';
4+
5+
parse(`
6+
a,b
7+
1,2
8+
3,4
9+
5,6
10+
`.trim(), {
11+
columns: true,
12+
to: 2
13+
}, function(err, records){
14+
console.log(err, records)
15+
assert.deepStrictEqual(
16+
records, [{
17+
a: '1',
18+
b: '2'
19+
}, {
20+
a: '3',
21+
b: '4'
22+
}]
23+
);
24+
});

0 commit comments

Comments
 (0)