-
-
Save brandonhall/973e70bde8e6a530c489 to your computer and use it in GitHub Desktop.
Dynamic CSV File Failing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
processCSV:function (filename) { | |
if (filename.indexOf("download") !== -1) { | |
console.log('Here: ' + filename); | |
var jsonObj = []; | |
csv() | |
.fromPath(__dirname + '/csv/' + filename, { | |
columns:true | |
}) | |
.on('data', function (data) { | |
if (data['E-mail Address'] !== null && data['First Name'] !== null) { | |
if(data['Last Name'] !== null) { | |
jsonObj.push({'name':data['First Name'] + ' ' + data['Last Name'], 'email':data['E-mail Address']}); | |
} else { | |
jsonObj.push({'name':data['First Name'], 'email':data['E-mail Address']}); | |
} | |
} | |
}) | |
.on('error',function(error){ | |
console.log(error.message); | |
}) | |
.on('end', function () { | |
getContacts.returnObject(jsonObj, filename); | |
}); | |
} else if (filename == 'ERROR') { | |
console.log('Unable to get contacts'); | |
} else if (filename == 'TIMEOUT') { | |
console.log('Unfortunately, your request timed out'); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment