1.0.6 • Published 10 months ago

@sdsjs/csv-parser v1.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

@sdsjs/csv-parser

A csv parser for lazy parse csv file, it is a async iterator, based on papaparse. Support:

  • http path
  • fs path (for nodejs)

Install

$ npm install @sdsjs/csv-parser

Usage

  • example one,use through asyn iterator:

    import { CsvParser } from "@sdsjs/csv-parser";
    async function test () {
      const csvParser = new CsvParser({
        path: [
          "E:\\test.csv",
          // "http://xxx/test.csv"
        ],
        logger: console,
        chunkSize: 1400000, // default chunkSize is `1400000` byte,if this parameter is not set
      });
      for await (let v of csvParser) {
        console.log(v)
      }
    }
    test();
  • example two,self call next:

    import { CsvParser } from "@sdsjs/csv-parser";
    async function test () {
      const csvParser = new CsvParser({
        path: [
          "E:\\test.csv",
          // "http://xxx/test.csv"
        ],
        logger: console,
        chunkSize: 1400000, // default chunkSize is `1400000` byte,if this parameter is not set
      });
      const temp = [];
      let ret = await csvParser.next();
      temp.push(...ret.value);
      while (!ret.done) {
        ret = await csvParser.next();
        !ret.done && temp.push(...ret.value);
      }
      return temp;
    }
    test();
1.0.6

10 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago