| 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]) |
|
|