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

trouble parsing csv input without final newline #5173

Closed
chrismo opened this issue Jul 8, 2024 · 1 comment
Closed

trouble parsing csv input without final newline #5173

chrismo opened this issue Jul 8, 2024 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@chrismo
Copy link

chrismo commented Jul 8, 2024

This example was reduced from a real CSV file, which had several fields, complete with inlined double-quotes, commas, and other potential hazards (I can't share the original file due to PII). Numbers and a few other programs parsed it correctly. zq parses it correctly, once I add a newline on the very last line of the file.

I can reproduce the same behavior with this:

# Unquoted simple strings, plus final newline (due to default `echo` behavior) - works fine
❯ echo "foo,bar\nfoo,bar" | zq -i csv -z 'yield this' -
{foo:"foo",bar:"bar"}

# Quoted string values, plus final newline - still works fine
❯ echo "foo,bar\n\"foo\",\"bar\"" | zq -i csv -z 'yield this' -
{foo:"foo",bar:"bar"}

# Quoted string values, but without a newline ending the contents (changed to `echo -n`), I receive this error message.
❯ echo -n "foo,bar\n\"foo\",\"bar\"" | zq -i csv -z 'yield this' -
stdio:stdin: parse error on line 2, column 10: bare " in non-quoted-field

# Removing the quotes from the values, still with no final newline (`echo -n`), works again.
❯ echo -n "foo,bar\nfoo,bar" | zq -i csv -z 'yield this' -
{foo:"foo",bar:"bar"}

❯ zq -version
Version: v1.16.0
@philrz
Copy link
Contributor

philrz commented Jul 9, 2024

Thanks @chrismo. It turns out this was already a known bug #4732 so I'm going to close this one as a duplicate and you can feel free to "Subscribe" to that one so you'll be notified when we fix it. It helps to have your report though because when we know community users keep bumping into these we need to boost the priority on getting them fixed.

@philrz philrz closed this as not planned Won't fix, can't repro, duplicate, stale Jul 9, 2024
@philrz philrz added the duplicate This issue or pull request already exists label Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants