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
-
What happens if you set delimiter to
','
explicitly? – Álvaro González Commented Dec 6, 2017 at 16:36
3 Answers
Reset to default 8CSV 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!