Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsv file with value containing double quote in non-quoted field #2156

Open
kermorgant opened this issue Sep 23, 2024 · 3 comments
Open

tsv file with value containing double quote in non-quoted field #2156

kermorgant opened this issue Sep 23, 2024 · 3 comments
Labels

Comments

@kermorgant
Copy link

Describe the bug

A tsv file with non quoted value including quotes like Caramel "Tradition" makes yq fail with parse error ...: bare " in non-quoted-field

Version of yq: 4.44.3
Operating system: linux
Installed via: binary release

Input tsv

test.csv:

Code    Name
1010    Caramel "Tradition"

Command
The command you ran:

yq -ptsv --tsv-auto-parse=f  -ojson test.csv

Error: bad file 'test.csv': parse error on line 2, column 14: bare " in non-quoted-field

Additional context
This error originally came from a tsv file downloaded from google spreadsheet using ?format=csv query param.

@mikefarah
Copy link
Owner

This is an error coming from golang's CSV parsing library (https://pkg.go.dev/encoding/csv) , seems like you need to do:

Code	Name
1010	"a ""quoted-field"""

To get it to work.

@kermorgant
Copy link
Author

kermorgant commented Oct 2, 2024

Indeed, that worked for my test file but unfortunately, I don't have control of the input file in my work environment (it's a direct download from a google spreadsheet).
There is a LazyQuote setting in https://pkg.go.dev/encoding/csv that would maybe offer a workaround. Would it make sense for yq to support that ?

@kermorgant
Copy link
Author

For what it's worth, I managed to workaround this issue by downloading the file as csv instead of tsv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants