I have a file that looks as follows :
I use a pattern to delete all digits within the brackets including the brackets.
It should work with one file but i want to open the first file with the text, do the manipulation, and then copy the result to file 2 (which is currently empty).
Can you check the following code and advise what should i correct ?
(By the way , i’m working under Ubuntu Linux so i included the full path of the text files).
import re file1 = open("/home/dror/Documents/1.txt","r") file2 = open("/home/dror/Documents/2.txt","w") data=file1.readline() b = [re.sub(r'\([^)]*\)','',data) for line in file1] file2.write(b) file1.close() file2.close()