How to read a csv file one line at a time and replace/edit certain lines as you go?

前端 未结 3 1633
盖世英雄少女心
盖世英雄少女心 2021-02-02 01:41

I have a 60GB csv file I need to make some modifications to. The customer wants some changes to the files data, but I don\'t want to regenerate the data in that file because it

3条回答
  •  面向向阳花
    2021-02-02 02:22

    Just read the file, line by line, with streamreader, and then use REGEX! The most amazing tool in the world.

    using (var sr = new StreamReader(new FileStream(@"C:\temp\file.csv", FileMode.Open)))
            {
                var line = sr.ReadLine();
                while (!sr.EndOfStream)
                {
                    // do stuff
    
                    line = sr.ReadLine();
                }
    
            }
    

提交回复
热议问题