0
Good evening guys, someone has already had the problem in importing a CSV where the first column of the file comes as Undefined?
// import_customers_service
import_customers_service('./data_files/customers_service.csv');
function import_customers_service(filename){
let stream = fs.createReadStream(filename);
let parser = csv.parse({
delimiter: ',',
columns: true
});
let transform = csv.transform(function(row) {
let resultObj = {
id: row['id'],
name: row['name']
}
console.log(resultObj);
});
stream.pipe(parser).pipe(transform)
}
Aquivo CSV
id,name
1,Yes
2,No
3,No phone service
Upshot:
{ id: undefined, name: 'Yes' }
{ id: undefined, name: 'No' }
{ id: undefined, name: 'No phone service' }
Has anyone ever seen anything about that mistake?
Hug