【问题标题】:Using PapaParse to Parse a Local File?使用 PapaParse 解析本地文件?
【发布时间】:2018-12-28 22:03:11
【问题描述】:

目前,我正在尝试parse a "local file"这个,

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)
} );

当我运行该代码时,这就是我返回的全部内容,

{ data: [],
  errors: [],
  meta:
   { delimiter: ',',
     linebreak: '\n',
     aborted: false,
     truncated: false,
     cursor: 17,
     fields: [ '../raw/M49/en.csv' ] }

【问题讨论】:

标签: papaparse


【解决方案1】:

Papa Parse 有三种模式,

  1. Parse String(显然不想要)
  2. Parse Remote File(你想要的)
  3. Parse Local File(命名错误,应为 Parse Web API File Object——特定于 Web API 中的“文件对象”)

这些都是浏览器用语,其中“本地文件”由File Object 表示。接受路径的选项是Parse a Remote File,这需要设置不直观的选项,

download: true

更糟糕的是,运行它会返回,

ReferenceError: XMLHttpRequest is not defined

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-11
    • 1970-01-01
    相关资源
    最近更新 更多