From 71a51e83a7f8b1397ce48e79f59645c7eda9b785 Mon Sep 17 00:00:00 2001 From: scoobybejesus Date: Tue, 27 Aug 2019 22:54:41 -0400 Subject: [PATCH] Removed unused code. --- src/cli_user_choices.rs | 4 -- src/csv_export.rs | 124 ++++++++++++++++++++-------------------- src/main.rs | 2 - 3 files changed, 63 insertions(+), 67 deletions(-) diff --git a/src/cli_user_choices.rs b/src/cli_user_choices.rs index 956dd6e..465bf87 100644 --- a/src/cli_user_choices.rs +++ b/src/cli_user_choices.rs @@ -22,8 +22,6 @@ pub fn choose_file_for_import() -> PathBuf { println!("Please input a file (absolute or relative path) to import: "); - // PathBuf::from("/Users/scoob/Documents/Repos/cryptools-rs/private/RawTxForImport-pycleaned.csv") - let file_str = _get_path(); PathBuf::from(file_str.unwrap()) } @@ -32,8 +30,6 @@ pub fn choose_export_dir() -> PathBuf { println!("Please input a file path for exports: "); - // PathBuf::from("/Users/scoob/Documents/Testing/rust_exports/") - let file_str = _get_path(); PathBuf::from(file_str.unwrap()) } diff --git a/src/csv_export.rs b/src/csv_export.rs index e8eed70..b72fdb6 100644 --- a/src/csv_export.rs +++ b/src/csv_export.rs @@ -1,7 +1,6 @@ // Copyright (c) 2017-2019, scoobybejesus // Redistributions must include the license: https://github.com/scoobybejesus/cryptools-rs/blob/master/LEGAL.txt -use std::rc::{Rc}; use std::fs::File; use std::collections::{HashMap}; use std::path::PathBuf; @@ -188,7 +187,7 @@ pub fn _2_account_sums_nonzero_to_csv( // rows.push(row); // } // } -// let buffer = File::create("/Users/scoob/Documents/Testing/rust_exports/test/txns-3rd-try.csv").unwrap(); +// let buffer = File::create(full_path).unwrap(); // let mut wtr = csv::Writer::from_writer(buffer); // for row in rows.iter() { // wtr.write_record(row).expect("Could not write row to CSV file"); @@ -364,70 +363,73 @@ pub fn _5_transaction_mvmt_summaries_to_csv( wtr.flush().expect("Could not flush Writer, though file should exist and be complete"); } -pub fn accounts_to_csv( - accounts: &[Rc], - ars: &HashMap, - raw_acct_map: &HashMap, - acct_map: &HashMap, - txns_map: &HashMap, -) { +// pub fn accounts_to_csv( +// accounts: &[Rc], +// ars: &HashMap, +// raw_acct_map: &HashMap, +// acct_map: &HashMap, +// txns_map: &HashMap, +// ) { - let mut rows: Vec> = [].to_vec(); - let mut header: Vec = [].to_vec(); +// let mut rows: Vec> = [].to_vec(); +// let mut header: Vec = [].to_vec(); - header.extend_from_slice(&[ - "#".to_string(), - "Account".to_string(), - "Ticker".to_string(), - "Margin".to_string(), - "Date".to_string(), - "Txn#".to_string(), - "Type".to_string(), - "Memo".to_string(), - "Amount".to_string(), - "Proceeds".to_string(), - "Cost basis\n".to_string(), - "Gain/loss".to_string(), - "Term".to_string(), - "Income".to_string(), - "Expense".to_string(), - ]); - rows.push(header); +// header.extend_from_slice(&[ +// "#".to_string(), +// "Account".to_string(), +// "Ticker".to_string(), +// "Margin".to_string(), +// "Date".to_string(), +// "Txn#".to_string(), +// "Type".to_string(), +// "Memo".to_string(), +// "Amount".to_string(), +// "Proceeds".to_string(), +// "Cost basis\n".to_string(), +// "Gain/loss".to_string(), +// "Term".to_string(), +// "Income".to_string(), +// "Expense".to_string(), +// ]); +// rows.push(header); - for acct in accounts { - for lot in acct.list_of_lots.borrow().iter() { - for mvmt in lot.movements.borrow().iter() { +// for acct in accounts { +// for lot in acct.list_of_lots.borrow().iter() { +// for mvmt in lot.movements.borrow().iter() { - let raw_acct = raw_acct_map.get(&acct.raw_key).unwrap(); - let txn = txns_map.get(&mvmt.transaction_key).unwrap(); - let mut row: Vec = [].to_vec(); +// let raw_acct = raw_acct_map.get(&acct.raw_key).unwrap(); +// let txn = txns_map.get(&mvmt.transaction_key).unwrap(); +// let mut row: Vec = [].to_vec(); - row.push(raw_acct.account_num.to_string()); - row.push(raw_acct.name.to_string()); - row.push(raw_acct.ticker.to_string()); - row.push(raw_acct.is_margin.to_string()); - row.push(mvmt.date.format("%Y/%m/%d").to_string()); - row.push(txn.tx_number.to_string()); - row.push(txn.transaction_type(ars, &raw_acct_map, &acct_map).to_string()); - row.push(txn.memo.to_string()); - row.push(mvmt.amount.to_string()); - row.push(mvmt.proceeds.get().to_string()); - row.push(mvmt.cost_basis.get().to_string()); - row.push(mvmt.get_gain_or_loss().to_string()); - row.push(mvmt.get_term(acct_map, ars).to_string()); - row.push(mvmt.get_income(ars, &raw_acct_map, &acct_map, &txns_map).to_string()); - row.push(mvmt.get_expense(ars, &raw_acct_map, &acct_map, &txns_map).to_string()); +// row.push(raw_acct.account_num.to_string()); +// row.push(raw_acct.name.to_string()); +// row.push(raw_acct.ticker.to_string()); +// row.push(raw_acct.is_margin.to_string()); +// row.push(mvmt.date.format("%Y/%m/%d").to_string()); +// row.push(txn.tx_number.to_string()); +// row.push(txn.transaction_type(ars, &raw_acct_map, &acct_map).to_string()); +// row.push(txn.memo.to_string()); +// row.push(mvmt.amount.to_string()); +// row.push(mvmt.proceeds.get().to_string()); +// row.push(mvmt.cost_basis.get().to_string()); +// row.push(mvmt.get_gain_or_loss().to_string()); +// row.push(mvmt.get_term(acct_map, ars).to_string()); +// row.push(mvmt.get_income(ars, &raw_acct_map, &acct_map, &txns_map).to_string()); +// row.push(mvmt.get_expense(ars, &raw_acct_map, &acct_map, &txns_map).to_string()); - rows.push(row); - } - } - } +// rows.push(row); +// } +// } +// } - let buffer = File::create("/Users/scoob/Documents/Testing/rust_exports/test/accts-1st-try.csv").unwrap(); - let mut wtr = csv::Writer::from_writer(buffer); +// let file_name = PathBuf::from("accounts_mvmts.csv"); +// let path = PathBuf::from(&settings.export_path); - for row in rows.iter() { - wtr.write_record(row).expect("Could not write row to CSV file"); - } - wtr.flush().expect("Could not flush Writer, though file should exist and be complete"); -} +// let buffer = File::create(full_path).unwrap(); +// let mut wtr = csv::Writer::from_writer(buffer); + +// for row in rows.iter() { +// wtr.write_record(row).expect("Could not write row to CSV file"); +// } +// wtr.flush().expect("Could not flush Writer, though file should exist and be complete"); +// } diff --git a/src/main.rs b/src/main.rs index 9180287..f513ad9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -305,8 +305,6 @@ fn main() -> Result<(), Box> { Ok(()) // // csv_export::transactions_to_csv(&transactions); - // // println!("\nReturned from `fn transactions_to_csv`. It worked!! Right?"); // csv_export::accounts_to_csv(&accounts); - // println!("\nReturned from `fn accounts_to_csv`. It worked!! Right?"); }