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_header(true)
.with_delimiter(b',')
.finish(df)
}
Read a csv file to a DataFrame
Example
use polars_core::prelude::*;
use polars_io::prelude::*;
use std::fs::File;
fn example() -> Result<DataFrame> {
// always prefer `from_path` as that is fastest.
CsvReader::from_path("iris_csv")?
.infer_schema(None)
.has_header(true)
.finish()
}
Modules
write
io_csv_write
APIs to write to CSV