Questions tagged [fast-csv]

Fast-csv on GitHub is a library that provides CSV parsing and formatting for node applications.

It uses the MIT license.

As of v0.2.0 fast-csv supports multi-line values.

58 questions
12
votes
2 answers

Node.js fast-csv synchronously read file and return array

I am trying to read a .csv file and to assign it to an array with this code: const fs = require("fs"); const csv = require("@fast-csv/parse"); let data = [] csv .parseFile("./downloads/aggiornamento.csv", { skipRows: 2 }) .on("error", (error)…
sanna
  • 1,398
  • 5
  • 16
  • 24
4
votes
1 answer

TypeError: csv.fromPath is not a function

I'm using fast-csv to read my csv file but it gives me error like this UnhandledPromiseRejectionWarning: TypeError: csv.fromPath is not a function Here is my code: const fileRows = []; console.log("req.file.path",req.file.path) // open uploaded…
Harsh Patel
  • 6,334
  • 10
  • 40
  • 73
3
votes
0 answers

How do I handle errors properly with fast CSV?

In the code below, I want to check if the headers are valid and then stop reading the stream if they are and send an error back to the client (via my ErrorHandler function). I see the following in my console: UnhandledPromiseRejectionWarning: Error:…
3
votes
1 answer

Node Express Fast CSV download to client

I've set up a small node js BE app, built with express and fastCsv module on top of it. The desired outcome would be to be able to download a csv file to the client side, without storing it anywhere inside the server, since the data is generated…
RGLSV
  • 2,018
  • 1
  • 22
  • 37
2
votes
0 answers

How to verify that the error condition is happening as expected

I have one of the quick examples (https://c2fo.github.io/fast-csv/docs/introduction/example) working import * as fs from 'fs'; import * as path from 'path'; import * as csv from 'fast-csv'; fs.createReadStream(path.resolve(__dirname, 'assets',…
Jeff
  • 2,728
  • 3
  • 24
  • 41
2
votes
2 answers

How to use async/await sequentially inside lambda function?

I am creating a Lambda Function which gets data from s3 bucket and stream it to fast-csv for parsing. After that, I need to connect to documentDB database to send those parsed data. But the problem is that sometimes the database connection function…
Fury
  • 151
  • 1
  • 9
2
votes
1 answer

With fast-csv how on data-invalid, how do I access the error object?

Using the fast-csv also supports async validation, with a callback example at fast-csv examples How do I get access to the error in the 'data-error' event? The validate event has a callback with prototype of error, boolean, string. .validate((row:…
Interlated
  • 5,108
  • 6
  • 48
  • 79
2
votes
1 answer

Trying to return 2D-array with fast-csv in Nodejs but returning none

I am attempting to parse a csv-file using fast-csv library and convert each values number or string to create 2d array. But I can't return array in ReadStream. Can you give me advice on my code? const fs = require("fs"); const csv =…
Pirikara
  • 343
  • 3
  • 12
1
vote
0 answers

How can I re-upload a CSV after processing it with fast-csv to S3 with streams?

I'm attempting to download csv files from S3, perform some transforms on the data (in this example, hardcoding an ID), and then reupload it back to S3 as a 'processed' version of the file whilst using streams to avoid running out of memory. Fast-csv…
ProEvilz
  • 5,310
  • 9
  • 44
  • 74
1
vote
0 answers

Node fast-csv on end not waiting for data function to finish

I am using fast-csv with node and have the situation of the jobs triggered by the end event starting before the data event stuff has finished. The slightly-edited code is the following: .on("data", record => { async.waterfall([ …
Dragan
  • 227
  • 3
  • 9
1
vote
1 answer

Reading csv with fast-csv in node.js when 3 columns have same captions

I am trying to read a CSV file with fast-csv in Node.js. The csv file has a header row which contains 90 columns. 87 of them have unique names. But 3 columns have the same header name "Transformation". This is obviously a semantic mistake. Fast-csv…
A.T.
  • 127
  • 9
1
vote
1 answer

"Failed to pipe. The response has been emitted already" when reading a stream (nodejs)

So my code is supposed to read some lines from a CSV file, convert them to an array of JSON objects, and return that array. To read the file as a stream, I am using got, and then using it in fast-csv. In order to return the resulting array, I put…
1
vote
0 answers

Why doesn't this CSV parsing Node Lambda log anything?

Runtime env is Node 14 (AWS Lambda function). The S3 bucket and Lambda function are in the same region, and the I have confirmed that the Lambda function is able to get the object from S3 (i.e. permissions does not seem to be an issue). The Lambda…
1
vote
1 answer

SequelizeUniqueConstraintError create method add only one row

I am trying to parse a csv file with fast-csv and at the end store all the lines in a database with sequelize Here is my script to parse the data: module.exports = async () => { try { let csvData = []; csv .parseFile(__basedir +…
Cissus
  • 15
  • 6
1
vote
0 answers

Handling Asynchronous stream: Read and Write multiple csv files after filtering dates in nodejs

So I have a bunch of csv files which have more data then I require, I want to filter the data out by only having keeping the rows with dates after year 2015. The Problem is that it works for a single file but when I enter multiple files it writes…
1
2 3 4