File size: 797 Bytes
c5aa6da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)