最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Papa Parse single column error Unable to auto-detect delimiting character; defaulted to ',' - Stack

programmeradmin7浏览0评论

I have a csv where only one column exists and I am using Papa Parse library to parse the csv. I receive the following error Unable to auto-detect delimiting character; defaulted to ','

Since it is only a single column it is not ma separated value. I tried to set delimeter config property to auto delimiter: "", but still the same problem

I have a csv where only one column exists and I am using Papa Parse library to parse the csv. I receive the following error Unable to auto-detect delimiting character; defaulted to ','

Since it is only a single column it is not ma separated value. I tried to set delimeter config property to auto delimiter: "", but still the same problem

Share Improve this question asked Dec 1, 2017 at 9:22 pantonispantonis 6,49719 gold badges71 silver badges136 bronze badges 1
  • What happens if you set delimiter to ',' explicitly? – Álvaro González Commented Dec 6, 2017 at 16:36
Add a ment  | 

3 Answers 3

Reset to default 8

CSV is far from being a standard. Even though there's a RFC, the format itself pre-dates the document, which anyway starts with:

It does not specify an Internet standard of any kind.

Plus CSV is often created by quick and dirty tools that couldn't care less about interoperability. In particular, even a well-known tool like Microsoft Excel generates different file formats depending on the regional settings of the puter where it runs!

All this means that, in order to parse a CSV file, you need to determine the exact file format and, in particular, which character is being used to separate different columns: despite the fact that the C in CSV stands for ma, it's just as mon to find semicolons. Depending on the software capabilities options include:

  • Tell the program
  • Let the program guess

In your case, guessing goes wrong because you only have one column, thus there aren't any separators in the file that the library can find. The error message is confusing, though, because it suggests there's a default separator (,) but it isn't actually defaulting to it.

Since guessing is neither possible nor needed, just tell it explicitly to use ,:

{
    delimiter: "",  // auto-detect <--------- We don't want this!
    newline: "",    // auto-detect
    quoteChar: '"',
    header: false,
    dynamicTyping: false,
    preview: 0,
    encoding: "",
    worker: false,
    ments: false,
    step: undefined,
    plete: undefined,
    error: undefined,
    download: false,
    skipEmptyLines: false,
    chunk: undefined,
    fastMode: undefined,
    beforeFirstChunk: undefined,
    withCredentials: undefined
}

If you set it to a single space delimiter:" " it will parse.

delimiter: "\n" works for me for single column!

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论