GithubHelp home page GithubHelp logo

jtwebman / csv-batch Goto Github PK

View Code? Open in Web Editor NEW
12.0 12.0 3.0 426 KB

Streaming CSV parser with no dependencies and has a batch event for lower memory processing in batches as well as a reducer for doing aggregations.

License: MIT License

JavaScript 100.00%
batch csv csv-parser reducer supports-promises

csv-batch's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

csv-batch's Issues

Last chunk not processed when batching

First of all: thanks for the library! ;-)

I think there's a problem if the number of rows in the csv doesn't match the batch size exactly.
The records of the last chunk won't be processed.

This test is currently failing:

it('works if batch size does not match row count exactly', () => {
    const csv = `a,b,c\n1,2,3\n4,5,6\n7,8,9`;
    let callCount = 0;
    return csvBatch(createStreamFromString(csv), {
      batch: true,
      batchSize: 2,
      batchExecution: batch => {
        callCount++;
        return `processed batch ${callCount} size ${batch.length}`;
      }
    }).then(results => {
      assert.equal(callCount, 2);
      assert.equal(results.totalRecords, 3);
      assert.deepEqual(results.data, ['processed batch 1 size 2', 'processed batch 2 size 1']);
      assert.isEmpty(results.errors);
    });
  });

I've prepared a pull request, but currently I'm not allowed to submit it...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.