當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript csvviewer.parseDSV函數代碼示例

本文整理匯總了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
      ]);
    });
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:28,代碼來源:parse.spec.ts

示例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
      ]);
    });
開發者ID:dalejung,項目名稱:jupyterlab,代碼行數:27,代碼來源:parse.spec.ts


注:本文中的@jupyterlab/csvviewer.parseDSV函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。