question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: csv(...).fromStream is not a function

See original GitHub issue

For the below code,

var csvfile = "../voter/test.csv";
var fs = require("fs");
var csv = require("fast-csv");
var stream = fs.createReadStream(csvfile);

var csvStream = csv()
  .fromStream(stream, { headers: true })
  .on("data", function(data) {
    console.log(data);
  })
  .on("end", function() {
    console.log(" End of file import");
  });

stream.pipe(csvStream); 

I am getting the following error,

.fromStream(stream, { headers: true })
   ^

TypeError: csv(...).fromStream is not a function
    at Object.<anonymous> (/***/test.js:26:4)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3

I crossed check the library files, the function is present. Anything I have missed out?

Node version : v8.12.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Maheswaecommented, Apr 10, 2020

This is because you might be using upper version of fast-csv package. try to use 2.4.1

0reactions
jomael-gemotacommented, Aug 29, 2020

This is because you might be using upper version of fast-csv package. try to use 2.4.1

Yep, this works for me. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node js does not parse the csv file using fast-csv library
Put the csv into a variable and then use stream.pipe() with it. Like this: var csvStream = csv .fromStream(stream, {headers : true}) ...
Read more >
fast-csv.fromStream JavaScript and Node.js code examples
Best JavaScript code snippets using fast-csv. ... csv.fromStream(stream, {headers : true}) .on("data", function(data){ console.log(data); }) .on("end", ...
Read more >
Top 5 fast-csv Code Examples - Snyk
To help you get started, we've selected a few fast-csv examples, based on popular ways it is used in public projects. · fast-csv...
Read more >
CSV parser and writer
fromStream (stream, options); function fast-csv.parse. ... objectMode = true; if (has(options, "transform")) { // remove so its not set to _transform in ...
Read more >
TypeError: csv is not a function in Nodejs - DevOps
TypeError : csv is not a function in Nodejs ... I am getting the following error in Nodejs, when I use a csv...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found