Download Dataset/transmethod/jsonl2json.py from KashiwaByte/DISC-Assignment: direct link, hf CLI and curl.
- Browser
- Download file 453 Bytes
-
https://huggingface.co/datasets/KashiwaByte/DISC-Assignment/resolve/main/Dataset/transmethod/jsonl2json.py
- Command line
-
hf download hf://datasets/KashiwaByte/DISC-Assignment/Dataset/transmethod/jsonl2json.py
-
curl -L -o jsonl2json.py https://huggingface.co/datasets/KashiwaByte/DISC-Assignment/resolve/main/Dataset/transmethod/jsonl2json.py
453 Bytes
| import json | |
| def convert_jsonl_to_json(jsonl_file, json_file): | |
| json_data = [] | |
| with open(jsonl_file, 'r') as file: | |
| for line in file: | |
| json_data.append(json.loads(line)) | |
| with open(json_file, 'w') as file: | |
| json.dump(json_data, file) | |
| # 使用示例 | |
| jsonl_file = 'Xtuner_Read_Comperhension50k.jsonl' | |
| json_file = 'Xtuner_Read_Comperhension50k.json' | |
| convert_jsonl_to_json(jsonl_file, json_file) |