C# Reading CSV data with correct cell format using Regex.
I am facing issue with CSV cell format.
My excel data is as below:
Date | Acct | Name 20210928 | 3.02+ 13 | ABC
where Acct is 14 digit number. But Acct number is displayed as in above format.
Code for reading excel data is as below:
var csvlines = File.ReadAllLines(file); Regex CSVParser = new Regex(",(?=(?:[^"]*"[^"]*")*(?![^"]*"))"); var csvLinesData = csvlines.Skip(1).Select(l => CSVParser.Split(l).ToArray());
With this code, CSV comma separated cells value will be added in Array.
But here for Acct field data is getting fetched as “3.02+ 13” but I need it as 14 digit number
How can I do that in above code? any thing to do with Regex?
Read more here: Source link