Aug-07-2022, 07:37 AM
(Aug-07-2022, 07:27 AM)Gribouillis Wrote: The slow part is the accumulative string concatenation at line 8 (the + operator). Try this codecan you belive it, it make hours to under a minute,
def good_lines(file): for line in file: line = line.strip() if line[:1] == '[' and line[-1] == ']': yield line + '\n' with open('input.raw') as ifh, open('output.raw', 'w') as ofh: ofh.writelines(good_lines(ifh))
thank you, I will give you reputation point