I have taken an interest in Rust as a hobby (I'm a hobbyist programmer, I have used python and C++ to automate things at work), and I'm currently trying to practice by porting some of my python code for data analysis to rust, however it has proven to be quite difficult to me as I'm a complete noob at this and most resources and documentation tend more towards intermediate and advanced rust users (at least for data science).
I'm trying to use the calamine crate to load a xlsx file into a Vec, however only the first row is parsed when using .next() method of the iterator in a for loop, so I'm clearly doing something wrong. As extra information which may be of help, the xlsx file consists of 23851 rows and 28 columns, and the actual data (not considering headers, which are not the be read) begins at position A3.
let range = excel
.worksheet_range("Sheet0")
.ok_or(calamine::Error::Msg("Cannot find Sheet0"))??;
let start = range.start().unwrap();
let end = range.end().unwrap();
// First cell to be read starts at 'A3', theres probably a better way to do this
let range = range.range((start.0 + 2, start.1), end);
println!("Start: {:?} - End: {:?}", range.start(), range.end());
let mut iter = RangeDeserializerBuilder::new().has_headers(false).from_range::<_, mr::RawMR>(&range)?;
let mut df: Vec<mr::RawMR> = Vec::new();
for result in iter.next() {
match result {
Ok(row) => { df.push(row); }
Err(e) => println!("Error: {}", e), };
}
// This prints 'Size: 1', I was expecting the total number of rows
println!("Size: {:?}", df.len());
This code only manages to read the first line of the excel file, and thus the vec contains only the first row.
Any help is greatly appreciated.
Thanks in advance