Papa Parse single column error Unable to auto-detect delimiting character; defaulted to ','
Asked Answered
C

3

5

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 comma separated value. I tried to set delimeter config property to auto delimiter: "", but still the same problem

Cloudland answered 1/12, 2017 at 9:22 Comment(1)
What happens if you set delimiter to ',' explicitly?Josie
L
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 computer 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 comma, it's just as common 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,
    comments: false,
    step: undefined,
    complete: undefined,
    error: undefined,
    download: false,
    skipEmptyLines: false,
    chunk: undefined,
    fastMode: undefined,
    beforeFirstChunk: undefined,
    withCredentials: undefined
}
Led answered 7/12, 2017 at 9:0 Comment(0)
H
2

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

Howerton answered 6/12, 2017 at 16:27 Comment(0)
H
0

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

Hive answered 10/11, 2020 at 16:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.