title: reading csv in nodejs and creating new file for each line
body: <p>I need to read a CSV file, iterate over each row, create a new file of the row and delete the row. So far , i have done this way</p>
  
  <pre><code>    var fs = require("fs"); // module
      var glob = require("glob");// helps to find file from globally using path
      var path = require("path");
  
      glob.sync(path.join(__dirname, "Database.csv")).forEach(function(csv_filename) {
      if (!(/_new\.csv$/.test(csv_filename))) {
      fs.readFile(csv_filename, "utf8", function(err, data) {
          if (err){ // if there is some mistakes
              console.log(err)
          }else{
              let stringTotal="";
              var arrayEachLines = data.split("\n");
            /*  arrayEachLines.forEach(function(line){    
              stringTotal=stringTotal+line+"\n";
                              */
              var o={};
  
              var i;
              var row;
                  for (i=0; i&lt;arrayEachLines.length; i++){
                  o[i]=arrayEachLines[i];
                  o[i]=o[i].replace(o[row],"");
  
              }
              arrayEachLines.push(o);
  
              console.log(o);
  
  
              fs.writeFile(csv_filename.replace(/Excel\.csv_original/, "Excel.csv_updated").replace(/\.csv$/, "_new.csv"), o[i], "utf8", function(err) {
                  if (err) {
                      console.log(err);
                  } else {
                      console.log(csv_filename + " converted");
                  }
              });
          }
  
      });
  }});
  </code></pre>
  
  <p>The database csv contains </p>
  
  <pre><code>  a,"﻿""blue""",11,3
    ba,"﻿""blue""",2,4
    c,"﻿""blue""",0,5
  </code></pre>
  
  <p>I want the system to read first row, create a new file with the fields of first row, delete the row and read second row do the same action
  Any suggestion will be highly appreciated guys</p>
  
  <p>Thank you</p>