Aug-07-2022, 06:50 AM
hi, sorry for my bad English,
I have code to remove line(s) that do not start with '[' and end with ']':
som how make my code faster?
I have code to remove line(s) that do not start with '[' and end with ']':
with open('input.raw') as f: lines = "" for line in f: lina = line.strip() #print(line) if lina.startswith("["): if lina.endswith("]"): lines = lines + lina + "\n" writing = open('output.raw', 'w') writing.write(lines) writing.close()but somehow my file is over 200Mb, and it take hour(s) to get it done,
som how make my code faster?