Input: large file around 12GB with sequence file, with ~ delimiter and I want to break after every 10th occurrence with new line.
I tried with
with open ("file.txt") as f:
for line in f:
x = line.count("~")
y = line.split("~")
s = ['Ç'.join(x) for x in [y[i:i + 10] for i in xrange(0, len(y), 10)]]
with open ("output.txt","w") as outfile:
outfile.write("~\n".join(s))
While line.split('~')
I'am getting memory error.
I tried with y = [line.split('~') for line in f]
but no use same error. Please assist me how to handle this issue.