title: How to parse CSV in CasperJS with Papa Parse?
body: <p>I am trying to load and parse a csv file in CasperJS with papa parse.</p>
  
  <p>This is the code for that task</p>
  
  <pre><code>var casper = require('casper').create({   
      verbose: true, 
      logLevel: 'debug',
      userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:34.0) Gecko/20100101 Firefox/34.0',
      pageSettings: {
          loadImages:  true,
          loadPlugins: false,
          webSecurityEnabled: false     
      },
      clientScript: [
          'jquery-2.1.3.min.js',
          'jquery.csv-0.71.min.js',
          'papaparse.min.js'
          ],
  
      viewportSize: {
          width: 1440,
          height: 900
      }
  });
  
  var fs = require('fs');
  
  casper.on('remote.message', function(msg) {
      this.echo('remote message caught: ' + msg);
  });
  
  casper.start();
  
  casper.then(function(){
  
      var input = fs.read('order4.csv');
  
      var config = {
          delimiter: "",  // auto-detect
          newline: "",    // auto-detect
          header: true,
          dynamicTyping: false,
          preview: 0,
          encoding: "",
          worker: false,
          comments: false,
          step: undefined,
          complete: undefined,
          error: undefined,
          download: false,
          skipEmptyLines: true,
          chunk: undefined,
          fastMode: undefined
      }
  
      var a = {'config' : config, 'input' : input}
  
  /*    var result = this.evaluate(function(input) {
              //console.log(input);
              var results = jquery.csv.toObjects(input);
              console.log(results);
              return results;
          },input);*/
  
      //var result = Papa.parse(a['input'],a['config']);
  
  
      var result = this.evaluate(function(a) { 
          console.log('111111111111111111111' + a['input']);
          var results = Papa.parse(a['input'],a['config']);
          console.log('2222222222222222222' + results);
  
          return results;
      },a);
  
      this.echo('333333333333333' + result);
  });
  
  casper.run();
  </code></pre>
  
  <p><code>$input</code> inside <code>evaluate</code> is visible but <code>$results</code> is null as well as <code>$result</code> in the last command. </p>
  
  <p>Is there a better way load and parse a csv file in CasperJS. How can call <code>Papa.parse</code> outside of <code>evaluate()</code> since I just want to load a local csv file.</p>