Skip to content

Instantly share code, notes, and snippets.

@rahatarmanahmed
Created December 9, 2015 21:41
Show Gist options
  • Save rahatarmanahmed/1bb04da08ecf92d98ab2 to your computer and use it in GitHub Desktop.
Save rahatarmanahmed/1bb04da08ecf92d98ab2 to your computer and use it in GitHub Desktop.
super dirty import script for node interactive attendant data
var Converter = require('csvtojson').Converter
var converter = new Converter({});
var request = require('superagent');
converter.on("end_parsed", function (jsonArray) {
jsonArray.map(function(contact){
var data = {
data: {
fullName: contact.first_Name + ' ' + contact.last_Name,
company: contact.Company,
email: contact.Email_Address
}
};
console.log(data);
request
.post('https://formio.form.io/nodeinteractive/submission')
.send(data)
.end(function(err, res){
if(err) return console.error(err);
console.log(res);
// Calling the end function will send the request
});
});
});
require("fs").createReadStream("./form.io.csv").pipe(converter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment