Skip to content

Unzip and parse downloaded big csv file #225

Closed Answered by reju1021
reju1021 asked this question in Q&A
Discussion options

You must be logged in to vote

Came eventually up with my own solution:

    const res = await fetch(url);
    const writeStream = fs.createWriteStream(fileNameToBeWritten);
    const nodeStream = Readable.fromWeb(res.body as unknown as ReadableStream);
    await finished(nodeStream.pipe(writeStream));

   await new Promise<void>((resolve, reject) => {
      const unzipper = new Unzip();

      unzipper.register(UnzipInflate);

      unzipper.onfile = (file) => {

        file.ondata = (err, chunk, final) => {
          if (err) {
            this.logger.error(err);
            file.terminate();
            reject(err);
          }

          const str = strFromU8(chunk);

          fs.appendFileSync(fileNameToBeWritten…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by reju1021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant