If you don't have memory to execute open("big.file").read(), then numpy will usually not help .. It uses the same memory as python variables (if you have 1 GB of RAM, you can only load 1 GB of data in numpy)
- . f = open("big.file", "rb"), f.read(500), . , / C..
, , . :
target_seq = "567"
input_file = "1234567890"
target_seq.read(5)
target_seq.read(5)
, len(target_seq) , , .
(-!):
while cur_data != "":
seek_start = 0
chunk_size = len(target_seq)
input_file.seek(offset = seek_start, whence = 1)
cur_data = input_file.read(chunk_size)
if target_seq == cur_data:
out_file.write("replacement_string")
else:
out_file.write(cur_data)
seek_start += 1
, ( ).