2

I am trying to write incoming data to a csv file. I tried to use http://csv.adaltas.com/generate/examples/

npm install csv

But I don't get the documentation. I just want to save some data into a csv file. But even the examples are not working. E.g. the example in the link above (Using the stream API) throws the following error message:

TypeError: Cannot read property 'eql' of undefined

(First I had to change the require path, after installing the csv full package I had to require it with:

var generate = require('csv/node_modules/csv-generate');

Obviously this guy uses the same node module: https://masteringmean.com/lessons/18-Writing-to-a-CSV-file-in-Nodejs

But I can't even get his code to work. I think it was made with an older (and better documented?!) version of the csv node module.

Can anyone help me? Maybe with some code, explaining the same basic things like the one seen in the link of masteringmean.com but for the newest version?

Thanks for any hints.

Cheers

2 Answers 2

1

should.eql() statement that triggers the error is an assertion made with Should. You have install it at first:

npm install should --save

And require it:

var should = require('should');

The error should disappear.

Sign up to request clarification or add additional context in comments.

Comments

0

better yet, just remove these lines:

output.should.eql('OMH,ONKCHhJmjadoA\nD,GeACHiN');

and/or

data.should.eql([ [ 'OMH', 'ONKCHhJmjadoA' ],[ 'D', 'GeACHiN' ] ]);

you really don't want the overhead of a library you're not using.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.