I wanted to read files from test-00000-of-00016, test-00001-of-00016 to test-00015-of-00016 and modify them and then write new files like
import json
with open('test-00000-of-00016.txt') as f, open('file-00000-of-00016.txt', 'w') as target:
for line in f:
l = json.loads(line)
l['utterance'] = l['utterance'].replace('play ', '', 1)
target.write(json.dumps(l))
How do I open and write files in sequence to do that instead of doing this manually?