public async Task <IActionResult> Post([FromRoute] Bank bank, IFormFile file) { string csvString; using (var stream = new MemoryStream()) { await file.CopyToAsync(stream); csvString = Encoding.UTF8.GetString(stream.ToArray()); } return(csvString .Split("\n") .Where(line => line.Length > 0) .Select(r => _transactionCleaner.Clean(r)) .Skip(1) .Select(line => new Row(line)) .Select(row => _statementParser.Parse(row.Cells)) .Pipe(trans => new Summary(trans)) .Pipe(summary => Ok(summary))); }
public string[] Parse(string input) { return(cleaner.Clean(input.Split(' ')).Where(w => regex.IsMatch(w)).ToArray()); }