Jefffrey commented on code in PR #10361:
URL: https://github.com/apache/arrow-rs/pull/10361#discussion_r3642680266


##########
arrow-csv/src/reader/mod.rs:
##########
@@ -351,6 +351,85 @@ impl Format {
         self
     }
 
+    /// Infer format settings from the CSV records in `reader`
+    ///
+    /// This currently infers whether the first record is a header. Up to
+    /// `max_records` records after the first record are inspected; if `None`, 
all
+    /// records are read. Detection is conservative and returns no header when 
the
+    /// sampled records do not provide type evidence.
+    ///
+    /// # Example
+    ///
+    /// ```
+    /// use arrow_csv::reader::Format;
+    /// use std::io::Cursor;
+    ///
+    /// let csv = "name,count\nalice,1\nbob,2\n";
+    /// let format = Format::default().infer_format(Cursor::new(csv), 
Some(10))?;
+    /// let (schema, records_read) = format.infer_schema(Cursor::new(csv), 
None)?;
+    ///
+    /// assert_eq!(schema.field(0).name(), "name");
+    /// assert_eq!(records_read, 2);
+    /// # Ok::<_, arrow_schema::ArrowError>(())
+    /// ```
+    pub fn infer_format<R: Read>(
+        mut self,
+        reader: R,
+        max_records: Option<usize>,
+    ) -> Result<Self, ArrowError> {

Review Comment:
   should we be returning no. of rows read like `infer_schema()`?



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