mholt/PapaParse

Option to Disable Auto-Escaping During Parsing

Open

#1039 aperta il 9 feb 2024

Vedi su GitHub
 (3 commenti) (1 reazione) (0 assegnatari)JavaScript (1157 fork)batch import
enhancementhelp wanted

Metriche repository

Star
 (11.877 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Summary: Many users of PapaParse may encounter CSV files that contain pre-escaped characters. In the current implementation, PapaParse automatically adds escaping to these characters, which results in double-escaped characters in the output. This behavior can be problematic for CSVs that are expected to contain escape characters as part of the data.

Issue: When parsing a CSV with pre-escaped quotes (either with a backslash or double quotes), PapaParse's parser automatically escapes these characters, leading to an unexpected doubling of escape characters in the output.

For example, an input CSV line like: "Test \"Test string\" Test","Definitely \"real\" cash" gets parsed to: ["Test \\\"Test string\\\" Test", "Definitely \\\"real\\\" cash"] instead of the expected: ["Test \"Test string\" Test", "Definitely \"real\" cash"]

Similarly, a value enclosed in triple quotes to signify an internal quote like: """Test \"Test string\" Test""" results in: ["\"Test \\\"Test string\\\" Test\""] which should ideally remain: ["""Test \"Test string\" Test"""]

Feature Request: It would be beneficial to have an option to disable auto-escaping entirely when parsing CSV files. This would allow users to work with CSV data that already includes the necessary escaping and expects it to be preserved as-is.

Guida contributor