import json for i in ["test.jsonl", "train.jsonl", "validation.jsonl"]: with open(f"data/processed/{i}") as f: tmp = [json.loads(l) for l in f.read().split("\n") if len(l) > 0] print(len(tmp)) for x in tmp: x["paragraph_question"] = f"question: {x['question']}, context: {x['paragraph']}" input() with open(f"data/processed/{i}", "w") as f: f.write("\n".join([json.dumps(x) for x in tmp]))