Closed xTMNTxRaphaelx closed 8 years ago
Can you give some sample code that isn't working?
Alright, this is a sample code i wrote right now..
'use strict';
const vopral= require('vorpal')().show();
const d3= require('d3');
function readCSV(csv_name, cb) {
// read file
d3.csv("cities.csv", function(data) {
cb(data);
});
}
vopral.command('read [csv_file_name]')
.action(function(args, cb) {
var self= this;
let str= args.csv_file_name;
// read csv
readCSV(str, function(data) {
// finish cb with another callback function
self.log(data);
cb();
});
})
// desperate try wishing something happen
.parse(process.argv);
/**
There is a big error showing right now. Saying
[ { 'Error: connect ECONNREFUSED 127.0.0.1:80': ' at Object.exports._errnoException (util.js:873:11)' },
{ 'Error: connect ECONNREFUSED 127.0.0.1:80': ' at exports._exceptionWithHostPort (util.js:896:20)' },
{ 'Error: connect ECONNREFUSED 127.0.0.1:80': ' at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1077:14)' },
columns: [ 'Error: connect ECONNREFUSED 127.0.0.1:80' ] ]
I think its because it cannot find such port.
CSV file is in same directory of it.
Also, when i tried such code at work, there wasnt even any error. I didnt understood what happened.
*/
Any help is fine.
Thanks.
This isn't really a Vorpal-related error. If you remove Vorpal from the picture and just run this d3.csv
method in Node, you'll come up with the same error, so I would focus on that end of it to reduce complexity.
What you were guessing on it trying to connect to and read the CSV is probably correct!
I am trying to parse a CSV inside my vorpal js command but it returning undefined always. Same function is working on browser.
Any suggestions on how to acheive it?