using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using CsvHelper; using BunyMuny; namespace BunyMuny { class Program { static int Main(string[] args) { Bank bank = Bank.ME; var statements = new List(); using (var sr = new StreamReader("/mnt/code/cs/bunymuny/test.csv")) { using (var csv = new CsvReader(sr, CultureInfo.InvariantCulture)) { csv.Read(); csv.ReadHeader(); // get the first line of the CSV file (the header) as a string string header = csv.Parser.Context.RawRecord; if (header == null) { Console.WriteLine("File is empty 0uo"); return 1; } else if (header == "Date,Description,Debits and credits,Balance") { bank = Bank.ME; } else if (header == "Whatever NAB uses I guess") { bank = Bank.NAB; } while (csv.Read()) { switch (bank) { case Bank.ME: double value = double.Parse(csv.GetField("Debits and credits").TrimStart().Replace("$", "")); statements.Add(new Statement() { Date = DateTime.ParseExact(csv.GetField("Date"), "dd/MM/yyyy", CultureInfo.InvariantCulture), Description = csv.GetField("Description"), Category = "Unknown", Value = value }); break; } } foreach (var statement in statements) { Console.WriteLine(statement); } } } return 0; } } }