Skip to content

Commit

Permalink
docs(csv-parse): to sample
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Nov 6, 2021
1 parent 4ec9e58 commit 6eed22a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/csv-parse/samples/option.from.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ import assert from 'assert';
import { parse } from 'csv-parse';

parse(`
a,b|1,2|3,4
a,b
1,2
3,4
5,6
`.trim(), {
columns: true,
record_delimiter: '|',
from: 2
}, function(err, records){
assert.deepStrictEqual(
records, [{
a: '3',
b: '4'
}, {
a: '5',
b: '6'
}]
);
});
24 changes: 24 additions & 0 deletions packages/csv-parse/samples/option.to.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

import assert from 'assert';
import { parse } from 'csv-parse';

parse(`
a,b
1,2
3,4
5,6
`.trim(), {
columns: true,
to: 2
}, function(err, records){
console.log(err, records)
assert.deepStrictEqual(
records, [{
a: '1',
b: '2'
}, {
a: '3',
b: '4'
}]
);
});

0 comments on commit 6eed22a

Please sign in to comment.