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

CSV parser not santizing values with colon #1733

Open
ErgEnn opened this issue Jul 20, 2023 · 0 comments
Open

CSV parser not santizing values with colon #1733

ErgEnn opened this issue Jul 20, 2023 · 0 comments
Labels

Comments

@ErgEnn
Copy link

ErgEnn commented Jul 20, 2023

Describe the bug
Given CSV with colon symbol in any value, the output YAML is not sanitized and the text preceding the colon is considered as part of key not part of value

Version of yq: 4.34.2
Operating system: windows
Installed via: binary release

Input CSV

data1.csv:

Index,Foo
1,Bar
2,ERROR: Baz not found

Command

yq -p=csv '.' .\data1.csv

Actual behavior

- Index: 1
  Foo: Bar
- Index: 2
  Foo:
    ERROR: Baz not found

Expected behavior

- Index: 1
  Foo: Bar
- Index: 2
  Foo: "ERROR: Baz not found"

Additional info
Since users probably want to use some more complex query
e.g.

yq -p=csv -o=csv '.|map(.Foo)' .\data1.csv  

they see the error

Error: csv encoding only works for arrays of scalars (string/numbers/booleans), child[1] is a !!map

instead so I include this error message here for SEO

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

1 participant