-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add quote style to csv writer #9004
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
Conversation
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @xanderbailey - this is looking good
| pub use self::reader::Reader; | ||
| pub use self::reader::ReaderBuilder; | ||
| pub use self::reader::infer_schema_from_files; | ||
| pub use self::writer::QuoteStyle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is publicly exporting something from the csv crate (which I think is good): https://docs.rs/csv/latest/csv/enum.QuoteStyle.html
arrow-csv/src/writer.rs
Outdated
| //! | ||
| //! ## Available Quoting Styles | ||
| //! | ||
| //! - `QuoteStyle::Necessary` (default): Only quotes fields when necessary (e.g., when they |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is redundant with the existing documentation on QuoteStyle -- the link above to QuoteStyle is probably fine
arrow-csv/src/writer.rs
Outdated
| .unwrap(); | ||
|
|
||
| // Test with QuoteStyle::Necessary (default) | ||
| let mut buf = Vec::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please reduce some of this boiler plate code? It is obscuring what is going on in the tests -- maybe a helper so these tests end up looking something like this:
assert_eq!(
"text,number,float\nhello,1,1.1\nworld,2,2.2\n\"comma,value\",3,3.3\n\"quote\"\"test\",4,4.4\n",
write_quote_style(batch, QuoteStyle::Necessary
)2fcd584 to
f1655ac
Compare
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @xanderbailey
Which issue does this PR close?
Following on from #8960, we are now exposing the quote style as a part of the csv writer options which allows users to quote columns similar to Spark's
quoteAllsetting.Rationale for this change
What changes are included in this PR?
Expose
QuoteStylein theWriterBuilderAre these changes tested?
Yes with examples and unit tests.
Are there any user-facing changes?