-
Notifications
You must be signed in to change notification settings - Fork 73
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
ux.Table: Incorrect parsing of double quotes when exporting to CSV #944
Comments
@julesbonnard Sounds like you've around got your head wrapped around a solution - any chance you'd be willing to submit a PR? |
Sure, I'm not used to but I'll try.
Le jeu. 22 févr. 2024, 22:41, Mike Donnalley ***@***.***> a
écrit :
… @julesbonnard <https://github.com/julesbonnard> Sounds like you've around
got your head wrapped around a solution - any chance you'd be willing to
submit a PR?
—
Reply to this email directly, view it on GitHub
<#944 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABD4XFQYWSJL6KLAWYVT5UDYU63PHAVCNFSM6AAAAABDARO3GOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRQGM3DINBUGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
julesbonnard
added a commit
to julesbonnard/core
that referenced
this issue
Feb 28, 2024
modify replace with replaceAll as mentioned in this issue : oclif#944 (comment)
mdonnalley
pushed a commit
that referenced
this issue
Mar 1, 2024
…977) * Fix: correctly escapes double quotes when converting ux.table to csv modify replace with replaceAll as mentioned in this issue : #944 (comment) * test: complete ux.table test to check if double quotes escaping is correct
mdonnalley
added a commit
that referenced
this issue
Mar 1, 2024
…977) (#980) * Fix: correctly escapes double quotes when converting ux.table to csv modify replace with replaceAll as mentioned in this issue : #944 (comment) * test: complete ux.table test to check if double quotes escaping is correct Co-authored-by: Jules Bonnard <[email protected]>
Closed by #980 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
The CSV output of ux.Table only escapes the first double quote of a string value, resulting in a bad CSV format when exporting string values with multiple double quotes followed by a comma.
To Reproduce
Try exporting with --csv flag a table containing the following string:
"That film", a great movie
.You get this wrong result:
"""That film", a great movie"
Expected behavior
According to CSV spec
If double-quotes are used to enclose fields, then a double-quote appearing inside a field must be escaped by preceding it with another double quote.
, the correct export should be"""That film"", a great movie"
Additional context
Problem seems to come from this line :
core/src/cli-ux/styled/table.ts
Line 153 in 6b9af08
Also, it would be great to only escape values containing characters like double quotes, commas and line breaks, and not the entire line
Thanks for your help
The text was updated successfully, but these errors were encountered: