xanderbailey commented on code in PR #8960:
URL: https://github.com/apache/arrow-rs/pull/8960#discussion_r2594240519
##########
arrow-csv/src/writer.rs:
##########
@@ -157,7 +163,22 @@ impl<W: Write> Writer<W> {
col_idx + 1
))
})?;
- byte_record.push_field(buffer.as_bytes());
+
+ // Apply whitespace trimming if options are enabled and the
column is a string type
+ let field_bytes = if should_trim &&
batch.column(col_idx).data_type() == &DataType::Utf8 {
+ let mut trimmed = buffer.as_str();
+ if self.ignore_leading_whitespace {
+ trimmed = trimmed.trim_start();
+ }
+ if self.ignore_trailing_whitespace {
+ trimmed = trimmed.trim_end();
+ }
Review Comment:
Very open to suggestions if this is the right way to go about this. It looks
like the other options are passed into `FormatOptions` but that's used much
more widely than just the CSV reader...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]