I just modified a text file using RegEx expressions in Google Collab. Specifically, I stripped a text file of three digit values. Now, I want to save the output and download the newly modified text file. How would I do this in Python?
For reference, here is my code.
filename = "gpt2historianregex.txt"
def main():
fh = open("gpt2historianregex.txt")
for line in fh:
print( re. sub('\d{3}','', text), end='')
if __name__ == "__main__": main()