You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
564 B
18 lines
564 B
use polars::frame::DataFrame;
|
|
use polars::prelude::*;
|
|
use std::io;
|
|
use std::io::Read;
|
|
|
|
/// Read from stdin from CSV format and return a Polars DataFrame
|
|
pub fn load_csv_from_stdin() -> PolarsResult<DataFrame> {
|
|
let mut buffer = String::new();
|
|
io::stdin().read_to_string(&mut buffer)?;
|
|
let cursor = io::Cursor::new(buffer.as_bytes());
|
|
CsvReader::new(cursor).finish()
|
|
}
|
|
|
|
/// Take a Polars Dataframe and write it as CSV to stdout
|
|
pub fn dump_csv_to_stdout(df: &mut DataFrame) -> Result<(), PolarsError> {
|
|
CsvWriter::new(io::stdout()).finish(df)
|
|
}
|