Module polars_io::csv [−][src]
This is supported on crate feature
csv-file
only.Expand description
(De)serializing CSV files
Maximal performance
Currently CsvReader::new has an extra copy. If you want optimal performance in CSV parsing/ reading, it is advised to use CsvReader::from_path.
Write a DataFrame to a csv file.
Example
use polars_core::prelude::*; use polars_io::prelude::*; use std::fs::File; fn example(df: &mut DataFrame) -> Result<()> { let mut file = File::create("example.csv").expect("could not create file"); CsvWriter::new(&mut file) .has_headers(true) .with_delimiter(b',') .finish(df) }
Read a csv file to a DataFrame
Example
use polars_core::prelude::*; use polars_io::prelude::*; use std::io::Cursor; let s = r#" "sepal.length","sepal.width","petal.length","petal.width","variety" 5.1,3.5,1.4,.2,"Setosa" 4.9,3,1.4,.2,"Setosa" 4.7,3.2,1.3,.2,"Setosa" 4.6,3.1,1.5,.2,"Setosa" 5,3.6,1.4,.2,"Setosa" 5.4,3.9,1.7,.4,"Setosa" 4.6,3.4,1.4,.3,"Setosa" "#; let file = Cursor::new(s); let df = CsvReader::new(file) .infer_schema(Some(100)) .has_header(true) .finish() .unwrap(); assert_eq!("sepal.length", df.get_columns()[0].name());
Structs
Create a new DataFrame by reading a csv file.
Write a DataFrame to csv.
A CSV writer builder