Unable to read huge (20GB) file from CPython

后端 未结 2 1535
终归单人心
终归单人心 2021-01-22 11:58

I have some CPython issue that I cannot understand. It all boils down to the fact that using the same code to read small text file works but cannot even read a single line from

2条回答
  •  攒了一身酷
    2021-01-22 12:28

    def my_readline(fh,delim):
        return "".join(iter(lambda:fh.read(1),delim))
    
    f = open(some_file)
    line = my_readline(f,"\r")
    

    should work if you can at least get .read(1) to work ... but if that doesnt work I dont know that anything will ... maybe use shell commands to split the file into smaller chunks somehow ... but I suspect beroe's answer is the real answer

提交回复
热议问题