本文整理汇总了TypeScript中@jupyterlab/csvviewer.parseDSV函数的典型用法代码示例。如果您正苦于以下问题:TypeScript parseDSV函数的具体用法?TypeScript parseDSV怎么用?TypeScript parseDSV使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parseDSV函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('does basic parsing of csv files', () => {
const data = `a,b,c,d\r\n0,1,2,3\r\n4,5,6,7`;
const options = { data };
let results;
results = parser({ ...options, columnOffsets: false });
expect(results.nrows).to.deep.equal(3);
expect(results.ncols).to.deep.equal(0);
expect(results.offsets).to.deep.equal([0, 9, 18]);
results = parser({ ...options, columnOffsets: true });
expect(results.nrows).to.deep.equal(3);
expect(results.ncols).to.deep.equal(4);
expect(results.offsets).to.deep.equal([
0,
2,
4,
6,
9,
11,
13,
15,
18,
20,
22,
24
]);
});
示例2: it
it('adjusts columns to match first row by default', () => {
let data = `a,b,c,d\n0,\n1,2,3,4,5,6`;
let options = { data, rowDelimiter: '\n' };
let results;
results = parser({ ...options, columnOffsets: false });
expect(results.nrows).to.eql(3);
expect(results.offsets).to.eql([0, 8, 11]);
results = parser({ ...options, columnOffsets: true });
expect(results.nrows).to.eql(3);
expect(results.ncols).to.eql(4);
expect(results.offsets).to.eql([
0,
2,
4,
6,
8,
10,
10,
10,
11,
13,
15,
17
]);
});