from os.path import dirname import json filename = dirname(__file__) + '/../voa/train.jsonl' with open(filename, 'r') as f: for line in f: data = json.loads(line) data['len2dur'] = round(data['length'] / data['duration'], 3) print(json.dumps(data))