Created keytree generator for u and cpi.
[?]
Jun 1, 2021, 10:19 PM
UCSU3QE4352YC4VOVI7GCSTNNA5FAHYURNJLJQEHY32BB6S3CZVACDependencies
- [2]
AIFRDCG2Split off countries mod into a separate crate. - [3]
4MG5JFXTFirst record. - [4]
IKPVWWLKFilter unemployment rate series. - [5]
AT753JPOSelected US unemployment series. - [6]
5POF332LWorking on fn cpi_included(). - [7]
GUXZCEWWAdded Country enum. - [8]
CUADTSHQSave csv data as multiple files. - [9]
LURDUHBIFinished series filter for CPI.
Change contents
- replacement in src/main.rs at line 5[2.24]→[3.44:59](∅→∅),[3.44]→[3.44:59](∅→∅),[3.25]→[3.10:26](∅→∅),[3.10]→[3.10:26](∅→∅),[3.26]→[3.22:47](∅→∅),[3.47]→[3.87:115](∅→∅),[3.87]→[3.87:115](∅→∅),[3.126]→[3.126:138](∅→∅),[3.37]→[3.59:84](∅→∅),[3.138]→[3.59:84](∅→∅),[3.26]→[3.59:84](∅→∅),[3.59]→[3.59:84](∅→∅),[3.66]→[3.107:110](∅→∅),[3.107]→[3.107:110](∅→∅)
use ui_data::{cpi_series,countries_with_data,save_unemployment_data,to_tag,unemployment_series,};use ui_data::*; - replacement in src/main.rs at line 8[3.127]→[3.88:146](∅→∅),[3.146]→[3.174:219](∅→∅),[3.174]→[3.174:219](∅→∅),[3.219]→[3.147:244](∅→∅),[3.244]→[3.139:222](∅→∅),[3.222]→[3.333:365](∅→∅),[3.333]→[3.333:365](∅→∅),[3.365]→[3.48:250](∅→∅),[3.250]→[3.617:626](∅→∅),[3.617]→[3.617:626](∅→∅),[3.626]→[3.251:787](∅→∅),[3.787]→[3.705:714](∅→∅),[3.705]→[3.705:714](∅→∅),[3.906]→[3.906:907](∅→∅),[3.907]→[3.788:853](∅→∅),[3.853]→[3.986:987](∅→∅),[3.986]→[3.986:987](∅→∅),[3.987]→[3.854:939](∅→∅),[3.939]→[3.1046:1047](∅→∅),[3.1046]→[3.1046:1047](∅→∅),[3.1047]→[3.940:1033](∅→∅),[3.1033]→[3.1108:1109](∅→∅),[3.1108]→[3.1108:1109](∅→∅),[3.1109]→[3.1034:1128](∅→∅),[3.1128]→[3.223:224](∅→∅),[3.1143]→[3.223:224](∅→∅),[3.224]→[3.1129:1189](∅→∅),[3.1189]→[3.275:276](∅→∅),[3.275]→[3.275:276](∅→∅),[3.329]→[3.1143:1144](∅→∅),[3.1143]→[3.1143:1144](∅→∅),[3.1144]→[3.1190:1252](∅→∅),[3.1252]→[3.383:384](∅→∅),[3.383]→[3.383:384](∅→∅),[3.384]→[3.1253:1418](∅→∅),[3.1418]→[3.532:542](∅→∅),[3.532]→[3.532:542](∅→∅),[3.542]→[3.1419:1440](∅→∅),[3.1440]→[3.1208:1209](∅→∅),[3.591]→[3.1208:1209](∅→∅),[3.1208]→[3.1208:1209](∅→∅),[3.1209]→[3.1441:1481](∅→∅),[3.1481]→[3.83:84](∅→∅),[3.633]→[3.83:84](∅→∅),[3.83]→[3.83:84](∅→∅),[3.84]→[2.25:97](∅→∅),[3.1551]→[3.1260:1261](∅→∅),[2.97]→[3.1260:1261](∅→∅),[3.703]→[3.1260:1261](∅→∅),[3.55]→[3.1260:1261](∅→∅),[3.148]→[3.1260:1261](∅→∅),[3.1260]→[3.1260:1261](∅→∅),[3.1261]→[2.98:148](∅→∅),[2.148]→[3.1552:1553](∅→∅),[3.1261]→[3.1552:1553](∅→∅),[3.1553]→[2.149:150](∅→∅)
// let data = unemployment_series(Country::Slovenia);// unemployment_data("LFHU24TTSIM647S");// let u = unemployment_data("LRUNTTTTSIQ156S");// inflation_series(Country::Slovenia);// save_data_csv("SVNCPHPLA01GPM");// save_series_meta("SVNCPHPLA01GPM");// println!("{:?}", data);// save_unemployment_data(&Country::SouthKorea);// for country in countries_with_data().iter() {// println!("\n{}", country.to_string());// save_unemployment_data(&country);// }// save_data_csv("LRHUTTTTNZA156N");// println!("{}", to_tag("unemployment", &Country::UnitedStates));// println!("{}", to_tag("unemployment", &Country::UnitedStates));// println!("{}", unemployment_series(&Country::NewZealand));// println!("{}", Fred::series_tags("NZLURHARMQDSMEI").unwrap().one_line());// Category attack// for i in 0..1000 {// match Fred::category(i) {// Ok(category) => println!("{}\n{}", i, category),// Err(json_err) => {},// }// }// let seriess = unemployment_series(&Country::NewZealand);// for series in seriess.iter() {// println!("{}", series.id);// }// let tag_seriess = Fred::tags_series("unemployment;rate;usa;nation").unwrap().seriess;// for tag_series in tag_seriess.iter() {// println!("{}", tag_series);// }// println!("{:?}", Fred::category_series(10).unwrap())// let series = Fred::series("LRHU24TTUSA156N").unwrap();// match Fred::series_tags("LRHU24TTUSA156N") {// Ok(series_tags) => println!("{}", series_tags),// Err(json_err) => println!("{}", json_err),// }// Relevant tags// unemployment, rate, nation, usa// println!("{}", unemployment_series(&Country::UnitedStates));save_unemployment_data(&Country::NewZealand);let root_dir = shellexpand::tilde("~/test_data");// save_all_cpi_data(&format!("{}/{}", root_dir, "/cpi"));// save_all_cpi_data_after(&Country::Israel, &format!("{}/{}", root_dir, "/cpi/israel"));// println!("{}", cpi_series(&Country::NewZealand));generate_keytree(&format!("{}/generated.keytree", root_dir)); - edit in src/main.rs at line 14
// Do searches by looking at titles - edit in src/lib.rs at line 3
use std::env; - edit in src/lib.rs at line 7
- replacement in src/lib.rs at line 11
/// Save FRED data to disk as csv./// Save FRED data to disk as csv, using full path. - edit in src/lib.rs at line 23
let save_path = format!("./data/{}", path); - replacement in src/lib.rs at line 49
fs::create_dir_all(&save_path).unwrap();fs::create_dir_all(&path).unwrap(); - replacement in src/lib.rs at line 53
save_path,path, - replacement in src/lib.rs at line 68
fs::create_dir_all(&save_path).unwrap();fs::create_dir_all(&path).unwrap(); - replacement in src/lib.rs at line 72
save_path,path, - replacement in src/lib.rs at line 85
pub fn save_series_meta(series_id: &str, path: &str) {pub fn save_series_meta(series_id: &str, full_path: &str) { - replacement in src/lib.rs at line 95
"./data/{}/{}.meta",path,"{}/{}.meta",full_path, - replacement in src/lib.rs at line 103
/// Return relevant CPI series for a country./// Returns relevant CPI series for a country, by pre-selecting series titles for each country./// - replacement in src/lib.rs at line 106
/// println!("{}", cpi_series(Country::NewZealand));/// println!("{}", cpi_series(&Country::NewZealand)); - replacement in src/lib.rs at line 108
pub fn cpi_series(country: Country) -> String {pub fn cpi_series(country: &Country) -> SeriesItems { - edit in src/lib.rs at line 461
.to_string() - replacement in src/lib.rs at line 985
/// Save csv data and meta data to file, for a given `Country`.pub fn save_unemployment_data(country: &Country) {/// Save csv data and meta data to file, for a given `Country` using full path./// ```/// save_unemployment_data(&Country::NewZealand, "/fullpath/data/new_zealand");/// ```pub fn save_unemployment_data(country: &Country, path: &str) { - edit in src/lib.rs at line 991
let path = country.as_path(); - replacement in src/lib.rs at line 997
pub fn update_all_unemployment_data() {/// Save csv data and meta data to file, for a given `Country` using full path./// ```/// save_cpi_data(&Country::NewZealand, "/fullpath/data/cpi/new_zealand");/// ```pub fn save_cpi_data(country: &Country, path: &str) {for series in cpi_series(country).iter() {save_data_csv(&series.id, &path);save_series_meta(&series.id, &path);println!("{}", series.id)}}/// Save csv data and meta data to file, for a given `Country`, using full path./// ```/// save_all_unemployment_data("/fullpath/data/u");/// ```pub fn save_all_unemployment_data(path: &str) { - replacement in src/lib.rs at line 1016
save_unemployment_data(&country);save_unemployment_data(&country, &format!("{}/{}", path, country.as_path()));}}/// Save csv data and meta data to file, for a given `Country`, using full path./// ```/// save_all_cpi_data("/fullpath/data/cpi");/// ```pub fn save_all_cpi_data(path: &str) {for country in countries_with_data().iter() {println!("\n{}", country.to_string());save_cpi_data(&country, &format!("{}/{}", path, country.as_path()));}}/// Generate the base keytree spec for all countries, using full path./// ```/// generate_keytree("/fullpath/data/generated.keytree");/// ```/// ```text/// source:/// html_page:/// data_type: u/// country: Australia/// graphic:/// height: 200/// data: AUSURAMS_a/// graphic:/// data: AUSURANAA_a/// graphic:/// ```// TODO: cpi, upub fn generate_keytree(path: &str) {let mut s = String::from("source:\n");// Unemploymentprintln!("u");for country in countries_with_data().iter() {s.push_str(" html_page:\n data_type: u\n");s.push_str(&format!(" country: {}\n", country));println!("{}", country.to_string());for series in unemployment_series(country).iter() {s.push_str(" graphic:\n data: ");s.push_str(&series.id);s.push('\n');}s.push('\n');};// CPIprintln!("cpi");for country in countries_with_data().iter() {s.push_str(" html_page:\n data_type: u\n");s.push_str(&format!(" country: {}\n", country));println!("{}", country.to_string());for series in cpi_series(country).iter() {s.push_str(" graphic:\n data: ");s.push_str(&series.id);s.push('\n');}s.push('\n');};fs::create_dir_all(&path).unwrap();fs::write(&path, s).unwrap();}/// Save csv data and meta data to file, for all countries after `Country` in the//'countries_with_data' list.pub fn save_all_cpi_data_after(after: &Country, path: &str) {for country in countries_with_data().iter().skip_while(|&country| country != after) {println!("\n{}", country.to_string());save_cpi_data(&country, &format!("{}/{}", path, country.as_path())); - edit in Cargo.toml at line 12
shellexpand = "2.1.0"