Skip to content

Commit

Permalink
fix quick-xml incompatible issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Binh Vu committed Nov 8, 2023
1 parent d40f091 commit 83f8c00
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 47 deletions.
47 changes: 18 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "drepr"
version = "1.2.0"
version = "1.2.1"
authors = ["Binh Vu <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "drepr"
version = "2.11.0"
version = "2.11.1"
description = "Data Representation Language for Reading Heterogeneous Datasets"
readme = "README.md"
requires-python = ">=3.8"
Expand Down
4 changes: 2 additions & 2 deletions readers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "readers"
version = "0.2.2"
version = "0.2.3"
authors = ["Binh Vu <[email protected]>"]
edition = "2018"

Expand All @@ -23,6 +23,6 @@ lazy_static = "1.4.0"
netcdf = { version = "0.7.0", features = ["static"] }

# for excel
calamine = "0.18.0"
calamine = "0.22.1"

pyo3 = "0.16.5"
30 changes: 16 additions & 14 deletions readers/src/spreadsheet/spreadsheet_ra_reader.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::prelude::{Index, Value, PathExpr, IndexIterator};
use crate::ra_reader::{RAReader, default_iter_index};
use crate::prelude::{Index, IndexIterator, PathExpr, Value};
use crate::ra_reader::{default_iter_index, RAReader};

use calamine::{open_workbook_auto, DataType, Reader};
use hashbrown::HashMap;


#[derive(Debug)]
pub struct SpreadsheetRAReader {
sheets: Vec<Value>,
Expand Down Expand Up @@ -33,6 +32,9 @@ impl SpreadsheetRAReader {
DataType::Int(v) => Value::I64(*v),
DataType::Float(v) => Value::F64(*v),
DataType::DateTime(v) => Value::F64(*v),
DataType::Duration(v) => Value::F64(*v),
DataType::DateTimeIso(v) => Value::Str(v.to_owned()),
DataType::DurationIso(v) => Value::Str(v.to_owned()),
DataType::Empty => Value::Str(String::new()),
DataType::Error(_) => Value::Null,
})
Expand All @@ -47,7 +49,11 @@ impl SpreadsheetRAReader {
}
}

return SpreadsheetRAReader { sheets, name2index, sheet_names };
return SpreadsheetRAReader {
sheets,
name2index,
sheet_names,
};
}
}

Expand All @@ -60,7 +66,7 @@ impl RAReader for SpreadsheetRAReader {
} else {
self.sheets[*v] = val;
}
},
}
Index::Str(v) => {
if start_idx < index.len() - 1 {
self.sheets[self.name2index[v]].set_value(index, start_idx + 1, val);
Expand All @@ -79,7 +85,7 @@ impl RAReader for SpreadsheetRAReader {
} else {
&self.sheets[*v]
}
},
}
Index::Str(v) => {
if start_idx < index.len() - 1 {
self.sheets[self.name2index[v]].get_value(index, start_idx + 1)
Expand All @@ -98,7 +104,7 @@ impl RAReader for SpreadsheetRAReader {
} else {
&mut self.sheets[*v]
}
},
}
Index::Str(v) => {
if start_idx < index.len() - 1 {
self.sheets[self.name2index[v]].get_mut_value(index, start_idx + 1)
Expand All @@ -115,12 +121,8 @@ impl RAReader for SpreadsheetRAReader {

fn remove(&mut self, index: &Index) {
let sheet_index = match index {
Index::Idx(v) => {
*v
},
Index::Str(v) => {
self.name2index[v]
}
Index::Idx(v) => *v,
Index::Str(v) => self.name2index[v],
};

self.sheets.remove(sheet_index);
Expand All @@ -138,4 +140,4 @@ impl RAReader for SpreadsheetRAReader {
fn iter_index<'a>(&'a self, loc: &PathExpr) -> Box<dyn IndexIterator + 'a> {
default_iter_index(self, loc)
}
}
}

0 comments on commit 83f8c00

Please sign in to comment.