Datasets:
Size:
10K - 100K
License:
| import json | |
| import os | |
| from tqdm import tqdm | |
| INPUT_JSON = "splice_segment_metadata.json" | |
| OUTPUT_JSONL = "metadata.jsonl" | |
| def convert_to_jsonl_ordered(): | |
| """ | |
| Converts the nested SPLICE JSON metadata into a flat, logically ordered | |
| JSON Lines file for a professional display in the Hugging Face Viewer. | |
| """ | |
| print(f"--- Converting to logically ordered '{OUTPUT_JSONL}' ---") | |
| with open(INPUT_JSON, 'r') as f: | |
| data = json.load(f) | |
| with open(OUTPUT_JSONL, 'w') as f_out: | |
| for video_info in tqdm(data, desc="Processing video tasks"): | |
| for segment in video_info.get("segments", []): | |
| output_record = { | |
| "file_name": segment.get("output_path", ""), | |
| "video_id": video_info.get("video_id", ""), | |
| "part": segment.get("part", -1), | |
| "label": segment.get("label", ""), | |
| "domain": video_info.get("Domain", ""), | |
| "class": video_info.get("class", ""), | |
| #"subset": video_info.get("subset", ""), | |
| "start": segment.get("start", -1.0), | |
| "end": segment.get("end", -1.0), | |
| #"segment_id": segment.get("segment_id", ""), | |
| "task_duration": video_info.get("duration", -1.0), | |
| "video_url": video_info.get("video_url", ""), | |
| } | |
| f_out.write(json.dumps(output_record) + '\n') | |
| print("\n--- Conversion Complete! ---") | |
| print(f"Successfully created '{OUTPUT_JSONL}' with a professional column order.") | |
| if __name__ == "__main__": | |
| convert_to_jsonl_ordered() |