I have a CSV file like this:
Header1;Header2;Header3;Header4;Header5;Header6
abc;123;xyz;...;...;...
I would like to add a new column at the end of this csv and directly merge column 1+2 in this new column:
Header1;Header2;Header3;Header4;Header5;Header6;Header7
abc;123;xyz;...;...;...;abc123
I was able to add a new column but how to add the data?
Here is what I'm using:
static void Main(string[] args)
{
String filePath = @"C:/Data.csv";
var csv = File.ReadLines(filePath)
.Select((line, index) => index == 0
? line + ";ExtID"
: line + ";" + line.ToString())
.ToList();
File.WriteAllLines(filePath, csv);
}