code: function outputFile(configId, outputdata){
    var fname= configId+ '_accounts.csv';
    console.log("Outputing file... "+fname);
    var input= {
      data: outputdata,
      fields: ['id','name','status','subscriptionStarts','subscriptionExpires']
    };
    json2csv(input, function(err, csv) {
      if (err) {
        console.log('ERROR!');
        console.log(err);
      } else {
        fs.writeFileSync(fname,csv);
      }
    });
  }
docs: Get all the accounts and apikeys for a partner account, output as CSV Write the output file