public List <SaleValues> GetDataFromCSV() { List <SaleValues> values = File.ReadAllLines(@"E:\Git Repo\DotNet5Demo\Algorithm\Icertis\data.csv") .Skip(1) .Select(v => SaleValues.FromCsv(v)) .ToList(); return(values); }
public static SaleValues FromCsv(string csvLine) { string[] values = csvLine.Split(','); SaleValues saleValues = new SaleValues(); saleValues.BuyerName = Convert.ToString(values[0]); saleValues.Address = Convert.ToString(values[1]); saleValues.Quantity = Convert.ToString(values[2]); saleValues.Product = Convert.ToString(values[3]); saleValues.Price = Convert.ToInt32(Convert.ToString(values[4]).Replace("Rs", "").Trim()); saleValues.ModeOfPayment = Convert.ToString(values[5]); return(saleValues); }