ukerandi
asked on
Nodej reading CSV file
Hi Experts,
I have write following code but getting error below
Code
I have write following code but getting error below
Code
var url = require('url');
var adr = 'https://storage.googleapis.com/tf-datasets/titanic/train.csv';
var q = url.parse(adr, true);
console.log(q.host);
console.log(q.);
const csv = require('csv-parser');
const fs = require('fs');
fs.createReadStream('https://storage.googleapis.com/tf-datasets/titanic/train.csv')
.pipe(csv())
.on('data', (row) => {
console.log(row);
})
.on('end', () => {
console.log('CSV file successfully processed');
});
Error :
storage.googleapis.com
CsvParser {
_readableState: ReadableState {
objectMode: true,
highWaterMark: 16,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: null,
pipesCount: 0,
flowing: null,
ended: false,
endEmitted: false,
reading: false,
sync: false,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
emitClose: true,
autoDestroy: false,
destroyed: false,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: false,
decoder: null,
encoding: null,
[Symbol(kPaused)]: null
},
readable: true,
_events: [Object: null prototype] {
prefinish: [Function: prefinish],
unpipe: [Function: onunpipe],
error: [Function: onerror],
close: [Function: bound onceWrapper] { listener: [Function: onclose] },
finish: [Function: bound onceWrapper] { listener: [Function: onfinish] },
survived: [Function],
alone: [Function]
},
_eventsCount: 7,
_maxListeners: undefined,
_writableState: WritableState {
objectMode: true,
highWaterMark: 16,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: false,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: false,
errorEmitted: false,
emitClose: true,
autoDestroy: false,
bufferedRequestCount: 0,
corkedRequestsFree: {
next: null,
entry: null,
finish: [Function: bound onCorkedFinish]
}
},
writable: true,
allowHalfOpen: true,
_transformState: {
afterTransform: [Function: bound afterTransform],
needTransform: false,
transforming: false,
writecb: null,
writechunk: null,
writeencoding: null
},
state: {
empty: '',
escaped: false,
first: true,
lineNumber: 0,
previousEnd: 0,
rowLength: 0,
quoted: false
},
_prev: null,
options: {
escape: 34,
headers: null,
mapHeaders: [Function: mapHeaders],
mapValues: [Function: mapValues],
newline: 10,
quote: 34,
raw: false,
separator: 44,
skipComments: false,
skipLines: null,
maxRowBytes: 9007199254740991,
strict: false,
customNewline: false
},
headers: null,
[Symbol(kCapture)]: false
}
Hint: hit control+c anytime to enter REPL.
events.js:292
throw er; // Unhandled 'error' event
^
Error: ENOENT: no such file or directory, open 'https://storage.googleapis.com/tf-datasets/titanic/train.csv'
Emitted 'error' event on ReadStream instance at:
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
and then change:
Open in new window
to:Open in new window