UUD3CJZLSTAVLMIXIWE4CHN5HQSFM6K3DCPWECJMKGXDOROK4G4AC
A6ZAYJNBYFXPUTCHTQDGAWUZIYOXNO3IJBN73ZX6PEJ3T4NMNOGQC
77SIQZ3EGGV6KSECMLPDKQFGEC7CCFAPWGER7ZARQ5STDKJNU6GQC
GUXZCEWWPBCHXO26JVWZ74CTSDFDDO775YR7FKY7UGVZCA7GCSYAC
SAHJYVNBUBBIUBI4ZMAXK4QJFOT54M5UA3W2HQMTNDSP3GGCRX7QC
4MG5JFXTKAE3SOVKGGNKEUTNCKOWEBHTGKVZHJWLWE3PTZTQKHPAC
2SABVMY3A2RZDF3KJXZSMJ2UQ4Q5EW422G4DVBJRKK26S2ESGVQAC
println!("{}", DataSelector::from_file("series_selector.keytree")
.resume_into_data_spec(Country::UnitedKingdom, DataType::Inf)
.unwrap()
.keytree());
// DataSpec::from_file("source_data.keytree").write(&root_dir);
// let series_obs = Fred::series_observations("NORURTOTADSMEI").unwrap();
// let () = series_obs;
// Get series_spec using series_id
let series_spec = SeriesSpec::from_series_id("NORURTOTADSMEI", "source_data.keytree").unwrap();
pub fn from_file(path: &str) -> Self {
let source_spec = fs::read_to_string(path).unwrap();
pub fn from_file(path: &str) -> Result<Self, Error> {
let source_spec = match fs::read_to_string(path) {
Ok(ss) => ss,
Err(err) => { return Err(failed_to_read_file(&err.to_string())) },
};
for (series_id, _) in &self.reverse {
let series_spec = self.get_series_spec(&series_id);
series_spec.write_data(root_path);
series_spec.write_meta(root_path);
for (_, series_specs) in &self.map {
for series_spec in series_specs {
series_spec.write_data(root_path);
series_spec.write_meta(root_path);
}
/// Return `Self` given a `series_id`.
pub fn from_series_id(series_id: &str, root_path: &str) -> Result<Self, Error> {
let sid = SeriesId::from_str(series_id).unwrap();
let data_spec = DataSpec::from_file(root_path)?;
let key = match data_spec.reverse.get(&sid) {
Some(key) => key,
None => { return Err(series_id_not_in_dataspec(&series_id.to_string())) },
};
match data_spec.map.get(&key) {
Some(series_specs) => {
Ok(
series_specs.iter()
.find(|series_spec| series_spec.series_id == sid)
.unwrap()
.clone()
)
},
None => unreachable!(),
}
}