read a very big single line txt file and split it

前端 未结 3 457
耶瑟儿~
耶瑟儿~ 2021-01-19 20:59

I have the following problem: I have a file which is nearly 500mb big. Its text, all in one line. The text is seperated with a virtual line ending, its called ROW_DEL and is

3条回答
  •  爱一瞬间的悲伤
    2021-01-19 21:39

    Read this file in chunks, for example use StreamReader.ReadBlock in c#. You can set the maximum number of characters to read there.

    For each readed chunk you can replace ROW_DEL to \r\n and append it to new file.

    Just remember to increase current index by the number of character you just read.

提交回复
热议问题