本文整理匯總了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
]);
});