Skip to content

CSV parser not santizing values with colon #1733

Open
@ErgEnn

Description

@ErgEnn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions