title: I get undefined values in my field value when inserting multiple documents after converting csv to json string and parsing. Why?
body: <p>Basically, I am trying to do an import function for csv files where the csv file will get converted to json before then being inserted into the mongodb. This is my code.</p>
  
  <pre><code>//require the csvtojson converter class 
  var Converter = require("csvtojson").Converter;
  // create a new converter object
  var converter = new Converter({});
  var MongoClient = require('mongodb').MongoClient;
  var url = 'mongodb://localhost:27017/myproject';
  
  // call the fromFile function which takes in the path to your 
  // csv file as well as a callback function
  converter.fromFile("./NTA-SAM-Inventory-List-Security-Management-
  New_2017.csv",function(err,result){
  // if an error has occured then handle it
  if(err){
      console.log("An Error Has Occured");
      console.log(err);  
  } 
  // the result of the conversion
  var jsonResult  = result;
  console.log(jsonResult);
  var jsobject= JSON.stringify(jsonResult);
  var jsonobject= JSON.parse(jsobject);
  var f = jsonobject.length;
  console.log(f);
  MongoClient.connect(url, function(err, db) {
          if(err) {
              console.log(err);
          }
          for(i = 0; i &lt; f; i++){
      var insertDocument = function() {
      db.collection('documents').insertOne({
  //'_id': Object.keys(obj).length,
          'indexNo' : jsonobject.indexNo,
          'samID': jsonobject.samID,
          'Type': jsonobject.Type,
          'InventoryStatus': jsonobject.InventoryStatus,
          'dateIn':jsonobject.dateIn,
          'Remarks':jsonobject.Remarks,
          'dateOut':jsonobject.dateOut,
          //'Remarks':jsonobject.remarks,
          'ntaSamRequestRef': jsonobject.ntaSamReqRef
          //'Created Date': "&lt;b&gt;" + day + "/" + month + "/" + year + "&lt;/b&gt;"
      }, function(err, results) {
          if(err) throw err;
          console.log(results);
  
      });
      };
          insertDocument(db, function() {
              if(err)
                  throw err;
              else{
                  console.log('insert');
              }
              db.close();
          });
          }   
   });
          console.log("Inserted " + f + " document into the documents 
          collection.");
   });
  </code></pre>
  
  <p>So far, I have tried doing this of converting a random file with 1400 records into a json string before parsing and then inserting it. But somehow I keep getting undefined from my fields whenever I insert, the result show my respective field with undefined values. </p>
  
  <p><strong>Which part of my <code>jsonobject.indexNo</code> is wrong in the sense that is <code>jsonobject.field1value</code> and <code>jsonobject.field2value</code> etc. How should I get the values from my json string then after parsing?</strong> </p>
  
  <p>I am using node.js to run it and mongodb as database. I can convert nicely just this part about inserting the documents inside. Thanks in advance!</p>