@Polachan Paily , Welcome to Microsoft Q&A, we could create a class for the csv file.
Then, we need to remove " " for every variable.
Here is a code example you could refer to.
static void Main(string[] args)
{
string[] fileContent = File.ReadAllLines(@"C:\Users\username\Desktop\t.csv").Select(i=>i.Replace("\"", "")).ToArray();
var result=(from line in fileContent
let Items = line.Split(',')
select new CsvContent
{
Col1 =Convert.ToInt32(Items[0]),
Col2 = Items[1],
Col3 = Items[2],
Col4 = Items[3],
Col5 = Items[4],
Col6 = DateTime.ParseExact(Items[5], "dd/MM/yyyy", CultureInfo.InvariantCulture),
Col7 = Items[6],
Col8 = Items[7],
Col9 =Convert.ToInt32( Items[8]),
Col10 = Convert.ToInt32(Items[9]),
Col11 = Items[10],
Col12= Items[11],
Col13= Convert.ToInt32(Items[12]),
Col14 = Convert.ToInt32(Items[13]),
Col15 = Convert.ToInt32(Items[14]),
Col16 = Items[15],
Col17= Convert.ToInt32(Items[16]),
Col18 = Items[17],
Col19= DateTime.ParseExact(Items[18], "HH:mm:ss", CultureInfo.InvariantCulture),
Col20 = DateTime.ParseExact(Items[19], "HH:mm:ss", CultureInfo.InvariantCulture),
Col21 = Items[20]
}).ToList();
}
public class CsvContent
{
public int Col1 { get; set; }
public string Col2 { get; set; }
public string Col3 { get; set; }
public string Col4 { get; set; }
public string Col5 { get; set; }
public DateTime Col6 { get; set; }
public string Col7 { get; set; }
public string Col8 { get; set; }
public int Col9 { get; set; }
public int Col10 { get; set; }
public string Col11 { get; set; }
public string Col12 { get; set; }
public int Col13 { get; set; }
public int Col14 { get; set; }
public int Col15 { get; set; }
public string Col16 { get; set; }
public int Col17 { get; set; }
public string Col18 { get; set; }
public DateTime Col19 { get; set; }
public DateTime Col20 { get; set; }
public string Col21 { get; set; }
}
Tested result:
Best Regards,
Jack