Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add csv example #4904

Merged
merged 2 commits into from
Oct 9, 2023
Merged

chore: add csv example #4904

merged 2 commits into from
Oct 9, 2023

Conversation

fansehep
Copy link
Contributor

@fansehep fansehep commented Oct 9, 2023

Which issue does this PR close?

Part of #1613

Rationale for this change

What changes are included in this PR?

add a example for arrow-csv.

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Oct 9, 2023

fn main() {
// read csv from file
let file = File::open("arrow-csv/test/data/example.csv").unwrap();
Copy link
Contributor Author

@fansehep fansehep Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I think don't need create a new file.

Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor nits

-->

# Examples
- [`csv_calculation.rs`](csv_calculation.rs): simple use the csv API to calcuate.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [`csv_calculation.rs`](csv_calculation.rs): simple use the csv API to calcuate.
- [`csv_calculation.rs`](csv_calculation.rs): performs a simple calculation using the CSV reader

Copy link
Contributor Author

@fansehep fansehep Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Good iead. 😄

Comment on lines 43 to 52
println!(
"max value column(0): {:?}",
s.column(0)
.as_any()
.downcast_ref::<Int16Array>()
.unwrap()
.iter()
.max()
.unwrap()
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
println!(
"max value column(0): {:?}",
s.column(0)
.as_any()
.downcast_ref::<Int16Array>()
.unwrap()
.iter()
.max()
.unwrap()
);
let col = s.column(0).as_primitive::<Int16Type>();
let max = col.iter().max().flatten();
println!("max value column(0): {max:?}");

With the necessary additional imports

Signed-off-by: fan <[email protected]>
@tustvold tustvold merged commit ed58e76 into apache:master Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants