tustvold commented on code in PR #3365:
URL: https://github.com/apache/arrow-rs/pull/3365#discussion_r1051685626


##########
arrow-csv/src/reader/mod.rs:
##########
@@ -177,11 +179,36 @@ pub fn infer_reader_schema<R: Read>(
     infer_reader_schema_with_csv_options(reader, roptions)
 }
 
+/// Creates a `csv::Reader`
+fn build_csv_reader<R: Read>(
+    reader: R,
+    has_header: bool,
+    delimiter: Option<u8>,
+    escape: Option<u8>,
+    quote: Option<u8>,
+    terminator: Option<u8>,
+) -> csv::Reader<R> {
+    let mut reader_builder = csv::ReaderBuilder::new();
+    reader_builder.has_headers(has_header);
+
+    if let Some(c) = delimiter {
+        reader_builder.delimiter(c);
+    }
+    reader_builder.escape(escape);
+    if let Some(c) = quote {
+        reader_builder.quote(c);
+    }
+    if let Some(t) = terminator {
+        reader_builder.terminator(csv::Terminator::Any(t));
+    }
+    reader_builder.from_reader(reader)
+}
+
 fn infer_reader_schema_with_csv_options<R: Read>(
     reader: R,
     roptions: ReaderOptions,
 ) -> Result<(Schema, usize), ArrowError> {
-    let mut csv_reader = Reader::build_csv_reader(
+    let mut csv_reader = build_csv_reader(

Review Comment:
   Schema inference still uses the old reader, both to reduce the size of this 
PR, but also because it is inherently row oriented, as opposed to parsing.



-- 
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]

Reply via email to