read a very big single line txt file and split it

前端 未结 3 460
耶瑟儿~
耶瑟儿~ 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:47

    Actually 500mb of text is not that big, it's just that notepad sucks. You probably don't have sed available since you're on windows but at least try naive solution in python, I think it will work fine:

    import os
    with open('infile.txt') as f_in, open('outfile.txt', 'w') as f_out:
      f_out.write(f_in.read().replace('ROW_DEL ', os.linesep))
    

提交回复
热议问题