I have a lot of different CSV files with data in it (including headers).
I can't figure it out how to add a new column in the position number two.
I can fill the new cell with the null value (each row) but the new column is in first position.
Please see attachment image : the new column it must be after the column IDINTA.
Can anybody help me?
Thanks in advance
My code below.
output = System.Web.HttpContext.Current.Server.MapPath("/public/target.csv");
string[] CSVDump = File.ReadAllLines(output);
List<List<string>> CSV = CSVDump.Select(x => x.Split('|').ToList()).ToList();
for (int i = 0; i < CSV.Count; i++)
{
CSV[i].Insert(0, i == 0 ? "Headername" : "Filename");
}
File.WriteAllLines(output, CSV.Select(x => string.Join("|", x)));
#Edit 01
#Edit 02
N|IDINTA|Filename|DDMMYYYY HHMMSS|

