Trying to add a column to the end of a cvs file, which will just count up the number of lines (or can all be the same number it doesn\'t really mater) as the main aim is to
Without examining much more, I can tell you that you definitely have a challenge with the lambda you're using for the update:
//add new column value for each row.
lines.Skip(1).ToList().ForEach(line =>
{
//-1 for header
lines[index] += "," + newColumnData[index - 1];
index++;
});
This would make more sense to me:
//add new column value for each row.
lines.Skip(1).ToList().ForEach(line =>
{
line += "," + newColumnData[++index - 2];
});
The lines[index]
part doesn't make sense in a ForEach
since you're looping through each line separately.