try_single / test.py
syficy's picture
Upload folder using huggingface_hub
c5aa6da verified
import json
def read_json(file_path):
with open(file_path, 'r') as file:
data = json.load(file)
return data
def write_json(file_path, data):
with open(file_path, 'w') as file:
json.dump(data, file, indent=4)
def read_jsonl(file_path):
with open(file_path, 'r') as file:
data = [json.loads(line) for line in file]
return data
def write_jsonl(file_path, data):
with open(file_path, 'w') as file:
for entry in data:
file.write(json.dumps(entry) + '\n')
data = read_jsonl("data.jsonl")
for item in data:
for ac in item["action_sequence"]:
ac["checkpoint_screenshot_path"] = "./data/"+str(item["id"])+"/"+ac["checkpoint_screenshot_path"]
write_jsonl("data_modified.jsonl", data)