GithubHelp home page GithubHelp logo

Breaks in streaming mode about csvjson HOT 3 OPEN

mcqj avatar mcqj commented on June 1, 2024
Breaks in streaming mode

from csvjson.

Comments (3)

mcqj avatar mcqj commented on June 1, 2024

Actually, looking at the code, it seems that streaming mode is not going to work since it calls the functions in app.js for every chunk and those functions output a complete array.

from csvjson.

charanguru avatar charanguru commented on June 1, 2024

I am also experiencing this issue. @pradeep-mishra please remove support for streaming data since it's clear that this is not supported at this time.

from csvjson.

ezcolombo avatar ezcolombo commented on June 1, 2024

bumped into this as well with not so big csv files ... (8914 lines / 760K) - think I solved it by piping through the following Transform before toObject. Anyway will be great to solve this correctly ...

const { Transform } = require('stream')

function friendlyChunks() {
    const queue = []

    return new Transform({
      transform(chunk, encoding, callback) {
        if (queue.length) {
          chunk = Buffer.concat([queue.pop(), chunk])
        }

        let offset = chunk.length

        for (let i = offset, found = false;
          (!found && i);
          i -= 1) {
          if (chunk[i] === 10
              || chunk[i] === 13) {
            found = true
            offset = i
          }
        }

        queue.push(Buffer.from(chunk.slice(offset + 1, chunk.length)))

        this.push(chunk.slice(0, offset))
        callback()
      },
    })
  }

read.pipe(FriendlyChunks()).pipe(toObject).pipe(stringify).pipe(write)

from csvjson.

Related Issues (20)

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.