-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
main.rs
31 lines (28 loc) · 995 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use polars::io::mmap::MmapBytesReader;
use polars::prelude::*;
fn main() -> PolarsResult<()> {
let file = std::fs::File::open("/home/ritchie46/Downloads/tpch/tables_scale_100/lineitem.tbl")
.unwrap();
let file = Box::new(file) as Box<dyn MmapBytesReader>;
let _df = CsvReader::new(file)
.with_delimiter(b'|')
.has_header(false)
.with_chunk_size(10)
.batched(None)
.unwrap();
// write_other_formats(&mut df)?;
Ok(())
}
fn _write_other_formats(df: &mut DataFrame) -> PolarsResult<()> {
let parquet_out = "../datasets/foods1.parquet";
if std::fs::metadata(&parquet_out).is_err() {
let f = std::fs::File::create(&parquet_out).unwrap();
ParquetWriter::new(f).with_statistics(true).finish(df)?;
}
let ipc_out = "../datasets/foods1.ipc";
if std::fs::metadata(&ipc_out).is_err() {
let f = std::fs::File::create(&ipc_out).unwrap();
IpcWriter::new(f).finish(df)?
}
Ok(())
}