This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c236700
commit d020b4d
Showing
5 changed files
with
68 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use std::sync::Arc; | ||
|
||
use futures::io::Cursor; | ||
use tokio::fs::File; | ||
use tokio_util::compat::*; | ||
|
||
use arrow2::array::*; | ||
use arrow2::error::Result; | ||
use arrow2::io::csv::read_async::*; | ||
|
||
#[tokio::main(flavor = "current_thread")] | ||
async fn main() -> Result<()> { | ||
use std::env; | ||
let args: Vec<String> = env::args().collect(); | ||
|
||
let file_path = &args[1]; | ||
|
||
let file = File::open(file_path).await?.compat(); | ||
|
||
let mut reader = AsyncReaderBuilder::new().create_reader(file); | ||
|
||
let schema = Arc::new(infer_schema(&mut reader, None, true, &infer).await?); | ||
|
||
let mut rows = vec![ByteRecord::default(); 100]; | ||
let rows_read = read_rows(&mut reader, 0, &mut rows).await?; | ||
|
||
let batch = deserialize_batch( | ||
&rows[..rows_read], | ||
schema.fields(), | ||
None, | ||
0, | ||
deserialize_column, | ||
)?; | ||
println!("{}", batch.column(0)); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters