public List <ProductCSVModel> Parse(string pathToFile) { CsvParserOptions options = new CsvParserOptions(true, ','); CSVProductMapping mapping = new CSVProductMapping(); CsvParser <ProductCSVModel> parser = new CsvParser <ProductCSVModel>(options, mapping); try { var result = parser.ReadFromFile(pathToFile, Encoding.UTF8).ToList(); result = result.ToList(); throw new NotImplementedException(); } catch (Exception e) { logger.LogError(e.Message); throw; } }
public async Task <List <ProductCSVModel> > Parse(string pathToFile) { CsvParserOptions options = new CsvParserOptions(true, ','); CSVProductMapping mapping = new CSVProductMapping(); CsvParser <ProductCSVModel> parser = new CsvParser <ProductCSVModel>(options, mapping); try { var mappingresult = await Task.Run(() => parser.ReadFromFile(pathToFile, Encoding.UTF8).ToList()); var result = mappingresult.Where(x => x.IsValid).Select(x => x.Result).ToList(); return(result); } catch (Exception e) { logger.LogError(e.Message); throw; } }