Questions tagged [node-csv-parse]

csv-parse is a parser for Node.js converting CSV text input into arrays or objects. It implements the stream API.

See npm page

73 questions
1
vote
3 answers

How to avoid for await...of with csv-parse

I am looking to be educated on this issue as I have spent a few days trying to resolve it on my own, to no avail. I am using csv-parse to parse a CSV file. I am using ESLint as my Linter I am using the Airbnb JavaScript Style Guide plugin for…
1
vote
1 answer

Saving data from a CSV in a global variable (fast-csv/papaparse)

I am new to js and trying to parse a CSV in the backend using node.js. I have an array of states in which I want to store the data of a column of CSV. This is a very simple code that i wrote using fast-csv to do so. But whenever I run the code, I…
Nitish
  • 15
  • 5
1
vote
0 answers

Vue.js - await for a single record from CSV to be retrieved using 'csv-parse' package

In my Vue.js application, I had to parse CSV file and upload each line to the backend. I would like to do it asynchronously so that the reading of the next record takes place after the previous record is already uploaded (promise resolved). import…
Przemek Baj
  • 426
  • 2
  • 5
  • 18
1
vote
1 answer

Returning dictionary created from CSV parser

I'm trying extract dictionary data like {Name:Value, Name2:Value2,...} from csv file like below ID,1,2,3,4,5,6,... Name,ABC,BCD,CDE,DEF,EFG,FGH,... Val,123,234,345,456,567,678,... using the function…
ysd
  • 191
  • 3
  • 12
1
vote
2 answers

How to read CSV data stored in Google Cloud Storage with Cloud Functions

As part of a communications effort to a large user base, I need to send upwards of 75,000 emails per day. The emails of the users I'm contacting are stored in a CSV file. I've been using Postman Runner to send these requests via SendGrid (Email…
1
vote
0 answers

Numeric column header for parsed CSV in JavaScript

I am using the CSV package for Node to parse some CSV files in a project. I need to be able to handle cases with and without a header. So either of: const withHeader = `h1,h2,h3 d1a,d2a,d3a d1b,d2b,d3b`; const withoutHeader =…
dpwr
  • 2,732
  • 1
  • 23
  • 38
1
vote
2 answers

Read csv file with nodejs with a max number rows

I'm trying to read a CSV file with node.js using the csv-parser library. Since it's a big file, I need to check the header and the first 100 rows and the stop the method and return true if everything is ok or false if the data doesn't respect the…
llandino
  • 75
  • 1
  • 7
1
vote
0 answers

How to get a readStream to point at a different file in a looped promise iteration

I'm trying to parse multiple CSV files into one JSON file. My problem is that that I cannot reuse the read stream as it does not update the file it's reading from. So for each iteration of the loop, I keep reading the first csv file passed to…
alexc
  • 1,250
  • 2
  • 17
  • 44
1
vote
0 answers

Get original line in the file using csv-parser in Node js

I am using csv-parser (https://www.npmjs.com/package/csv-parser) to parse the CSV file something like below: const csv = require('csv-parser') const fs = require('fs') const results = []; fs.createReadStream('data.csv') .pipe(csv()) .on('data',…
hatellla
  • 4,796
  • 8
  • 49
  • 101
1
vote
1 answer

Using csv-parse without a loop

I'm using the csv-parse Node package to parse a CSV string. The documentation suggests that I read the parsed result using something like this: const output = [] parse(` "1","2","3" "a","b","c" `) .on('readable', function() { let record …
slifty
  • 13,062
  • 13
  • 71
  • 109
1
vote
0 answers

Pushing csv file dataframe to an array

I have this piece of code done in Javascript, where I want to save the name of colleges from an csv file to an array named results. Although I can print values while I am inside the function the array is empty when I print it out of the function. …
Learner
  • 33
  • 6
1
vote
1 answer

Getting CSV headers without reading whole Stream

I'm using the csv-parser node module to capture the headers of streaming csv files; there's a 'headers' event emitter I'm using that's built into the module. I'm looping through an array of csv readstreams that I'm passing through my getHeaders()…
alyslov
  • 95
  • 7
1
vote
1 answer

Why is CreateReadStream not firing error event?

I am attempting to do some error handling for a csv file. When changing the name of the file to something that does not exists, Error: ENOENT: no such file or directory, open 'testdat.csv' is displayed but the on error event is not fired. Here is…
Amir
  • 318
  • 1
  • 9
1
vote
1 answer

return value is not working outside the function?

when we console.log(restaurantdata) inside the .on('end') function return log but outside function log cant give value return undefined. var restaurantdata=[]; fs.createReadStream('restaurantsa9126b3.csv') .pipe(csv()) .on('data',…
1
vote
1 answer

how to use read and write stream of csv-parse

hello guys i m new over here and got confuse how i can use readstream and write stream right now i tried this(i m using this library https://www.npmjs.com/package/csv-parse) fs.createReadStream(path.join(__dirname,"../demofile/Customers.csv")) …
Rocky
  • 319
  • 3
  • 8
  • 23