File size: 721 Bytes
9af963d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import json
import sys

def extract(instance_id, input_file="java_data.jsonl"):
    with open(input_file) as f:
        for line in f:
            record = json.loads(line)
            if record["instance_id"] == instance_id:
                output_file = f"java_data_{instance_id}.jsonl"
                with open(output_file, "w") as out:
                    out.write(json.dumps(record, ensure_ascii=False, indent=2) + "\n")
                print(f"Saved to {output_file}")
                return
    print(f"instance_id '{instance_id}' not found in {input_file}")

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print(f"Usage: {sys.argv[0]} <instance_id>")
        sys.exit(1)
    extract(sys.argv[1])