public IEnumerable<Transaction> GetTransactions(string fileContent) { DataProviderExtensions.CheckFormatSupported(this, fileContent); var lines = DataProviderExtensions.SplitStringIntoLines(fileContent.Substring(fileContent.IndexOf(transactionStart))); var csvParser = new CsvLineParser(); foreach (var line in lines.Skip(1)) { var parsed = csvParser.Parse(line); if (parsed[1].StartsWith("Beginning balance as of ")) { continue; } var transaction = new Transaction { Date = DateTime.ParseExact(parsed[0], "MM/dd/yyyy", CultureInfo.InvariantCulture), Description = parsed[1], Amount = double.Parse(parsed[2]) }; yield return transaction; } yield break; }
public IEnumerable<Transaction> GetTransactions(string fileContent) { DataProviderExtensions.CheckFormatSupported(this, fileContent); var lines = DataProviderExtensions.SplitStringIntoLines(fileContent); var csvParser = new CsvLineParser(); foreach (var line in lines.Skip(1)) { var s = csvParser.Parse(line); var transaction = new Transaction(); transaction.Date = DateTime.ParseExact(s[1], "MM/dd/yyyy", CultureInfo.InvariantCulture); transaction.Description = s[3]; transaction.Amount = double.Parse(s[4]); yield return transaction; } yield break; }