0

Currently, I'm trying to parse a "local file" this,

import Papa from 'papaparse';

Papa.parse( '../raw/M49/en.csv', {
  header: true,
  delimiter: ',',
  complete: (res) => console.log("COMPLETE", res),
  error: err => console.log("ERROR", err)
} );

When I run that code, this is all I get back,

{ data: [],
  errors: [],
  meta:
   { delimiter: ',',
     linebreak: '\n',
     aborted: false,
     truncated: false,
     cursor: 17,
     fields: [ '../raw/M49/en.csv' ] }
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
  • Possible duplicate of [How can I read a local file with Papa Parse?](https://stackoverflow.com/questions/49752889/how-can-i-read-a-local-file-with-papa-parse) – Evan Carroll Dec 28 '18 at 22:14

1 Answers1

1

Papa Parse has three modes,

  1. Parse String (Obviously don't want it)
  2. Parse Remote File (what you want)
  3. Parse Local File (misnamed, should be Parse Web API File Object -- specific to a "File Object" from the Web API)

These are both in browser-parlance where a "LOCAL FILE" is represented by a File Object. The option that accepts a path, is to Parse a Remote File, this requires setting the unintuitive option,

download: true

Even worse, running this will return,

ReferenceError: XMLHttpRequest is not defined
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468