Skip to content

Commit

Permalink
Set up csv library
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbut committed Jul 11, 2020
1 parent 675fc27 commit 1641af3
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 1 deletion.
Binary file added .DS_Store
Binary file not shown.
87 changes: 87 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
csv = "1.1"
Binary file added resources/.DS_Store
Binary file not shown.
26 changes: 26 additions & 0 deletions resources/transactions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Date, Type, Description, Value, Balance, Account Name, Account Number
,,,,,,
10/07/2020,DPC,"'LUCINDA MERCER , HAR-082 , VIA ONLINE - PYMT , FP 10/07/20 10 , 02105209877466000N",-470,33053.99,'SELLECTLETS LTD,'600525-21099146
10/07/2020,DPC,"'ROSSLYN HOWARD , WAR-003 , VIA ONLINE - PYMT , FP 10/07/20 10 , 52105127171110000N",-641.2,33523.99,'SELLECTLETS LTD,'600525-21099146
10/07/2020,DPC,"'393 COMMUNICATIONS, PAL-040F1 , VIA ONLINE - PYMT , FP 10/07/20 10 , 09104908415255000N",-490.6,34165.19,'SELLECTLETS LTD,'600525-21099146
10/07/2020,DPC,"'REPOSSESSION REMED, NEW-010 , VIA ONLINE - PYMT , FP 10/07/20 10 , 11114654171233000N",-359.56,34655.79,'SELLECTLETS LTD,'600525-21099146
10/07/2020,DPC,"'LISA FIELDING , PLU-044 , VIA ONLINE - PYMT , FP 10/07/20 10 , 22105243245856000N",-374,35015.35,'SELLECTLETS LTD,'600525-21099146
10/07/2020,DPC,"'KALPESH LAKHANI , COU-008GF , VIA ONLINE - PYMT , FP 10/07/20 10 , 28105722392466000N",-474.6,35389.35,'SELLECTLETS LTD,'600525-21099146
10/07/2020,DPC,"'A MERCER AND M GALL , KAT 011 , VIA ONLINE - PYMT , FP 10/07/20 10 , 24105046292965000N",-493.5,35863.95,'SELLECTLETS LTD,'600525-21099146
10/07/2020,DPC,"'OLIVER YOXALL DODD, BIR-007 , VIA ONLINE - PYMT , FP 10/07/20 10 , 33104831508648000N",-542.4,36357.45,'SELLECTLETS LTD,'600525-21099146
10/07/2020,DPC,"'CJ RYAN / D LUCOCK, VARIOUS , VIA ONLINE - PYMT , FP 10/07/20 10 , 14110003741635000N",-815,36899.85,'SELLECTLETS LTD,'600525-21099146
10/07/2020,DPC,"'CLARKE ELECTRICAL , SELLECT HOMES , VIA ONLINE - PYMT , FP 10/07/20 10 , 17105922989002000N",-45,37714.85,'SELLECTLETS LTD,'600525-21099146
10/07/2020,DPC,"'PKG PROPERTIES , ALD-021H , VIA ONLINE - PYMT , FP 10/07/20 10 , 62105001343848000N",-484,37759.85,'SELLECTLETS LTD,'600525-21099146
10/07/2020,DPC,"'TO A/C 21099138, VIA ONLINE - XFER",-504,38243.85,'SELLECTLETS LTD,'600525-21099146
10/07/2020,DPC,"'TO A/C 21099138, VIA ONLINE - XFER",-1290,38747.85,'SELLECTLETS LTD,'600525-21099146
10/07/2020,DPC,"'CJP PROPERTIES , DEN-011 , VIA ONLINE - PYMT",-453.42,40037.85,'SELLECTLETS LTD,'600525-21099146
10/07/2020,DPC,"'TO A/C 21099138, VIA ONLINE - XFER",-6915.71,40491.27,'SELLECTLETS LTD,'600525-21099146
10/07/2020,DPC,"'JSB GAS , SL-093 , VIA ONLINE - PYMT",-36,47406.98,'SELLECTLETS LTD,'600525-21099146
10/07/2020,BAC,"'ENTWISTLE JE , COU-008GF",525,47442.98,'SELLECTLETS LTD,'600525-21099146
10/07/2020,BAC,"'PIGOVA M , HAR-082 , FP 10/07/20 0121 , RP4671365619066000",500,46917.98,'SELLECTLETS LTD,'600525-21099146
10/07/2020,BAC,"'SOFIA BERNDT , DEN-011 , FP 10/07/20 0312 , PLYP19WO1WUA6C7HEE",495,46417.98,'SELLECTLETS LTD,'600525-21099146
10/07/2020,BAC,"'MR OVERTON , PLU-044 , FP 10/07/20 0130 , 000000000093265745",425,45922.98,'SELLECTLETS LTD,'600525-21099146
10/07/2020,BAC,"'BCARD1153531090720, FP 10/07/20 0853 , BW2399547424819100, BCARD",1084.15,45497.98,'SELLECTLETS LTD,'600525-21099146
10/07/2020,BAC,"'JAMES MUAT , ALEXP-005 , FP 10/07/20 0721 , 200710072102876013",53,44413.83,'SELLECTLETS LTD,'600525-21099146
10/07/2020,BAC,"'ANTONI F R , GLYNNE-011 , FP 10/07/20 0113 , RP4653085189000900",265.38,44360.83,'SELLECTLETS LTD,'600525-21099146
10/07/2020,BAC,"'J MALONE , BAR-023 , FP 10/07/20 0843 , 100000000620553110",495,44095.45,'SELLECTLETS LTD,'600525-21099146
27 changes: 26 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
use csv::Reader;
use std::error::Error;
use std::fs::File;

fn read_transactions_csv(file_name: &str) -> Result<(), Box<dyn Error>> {

println!("Reading transactions from file: {}", file_name);

let mut reader = Reader::from_path(file_name)?;
for result in reader.records() {

let record = result?;
println!("{:?}", record);

}

Ok(())

}

fn main() {
println!("Hello, world!");

let current_dir = std::env::current_exe().unwrap().to_str().unwrap().to_owned();
let file_name = current_dir + "/../../../resources/transactions.csv";
let mut file = File::open("foo.txt");
//read_transactions_csv(&file_name);

}

0 comments on commit 1641af3

Please sign in to comment.