Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. prospectsDB.changes(since, function(err, doc){
  2.  
  3. prospectsDB.get(doc.id, function(err, doc){
  4.  
  5. var csvEntry ="";
  6. console.log('changes');
  7.  
  8. if(doc){
  9. console.log('since: '+since);
  10. for(value in doc){
  11.  
  12. //replace any semicolos with commas and use a semi colon as the delimiter.
  13. csvItem = JSON.stringify(doc[value]);
  14. csvItem = csvItem.replace(';',',');
  15. csvEntry += csvItem + ';';
  16.  
  17. console.log(value+' : '+csvItem);
  18.  
  19. }
  20.  
  21. console.log('doc')
  22.  
  23. var csvEntry = csvEntry + "\n";
  24. var filename = '/home/virtual/vibrantrioja.com/var/www/html/grandtasting/signups.csv';
  25. fs.open(filename, 'a',0666,function(err,fd) {
  26.  
  27. console.log('open');
  28.  
  29. fs.write(fd,csvEntry,null,'utf-8',function(err,fd){
  30.  
  31. fs.close(fd);
  32. console.log('write');
  33. console.log(csvEntry);
  34. });
  35. });
  36.  
  37. newSignUps = 1;
  38.  
  39. }
  40. });
  41.  
  42. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement