Question

I want to read a .csv file which has some repeated lines. I want to read between this repeated line. For example a is the repeated line and before the second a, I have lines such as 1,2,3.

I want to read write these values between a values. Can you help me?

Was it helpful?

Solution

It was a bit unclear. But perhaps this will do:

var lines = new List<string>(File.ReadLines("input.csv"));
foreach (string line in lines)
{
    if (line.StartsWith("a")) continue;
    // insert code to modify the other lines
}
// ... and later
File.WriteAllLines("output.csv", lines);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top