Download debug_json.py from elijah12e3rfr/law_processed: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/elijah12e3rfr/law_processed/resolve/main/debug_json.py
- Command line
-
hf download hf://elijah12e3rfr/law_processed/debug_json.py
-
curl -L -o debug_json.py https://huggingface.co/elijah12e3rfr/law_processed/resolve/main/debug_json.py
1.34 kB
| #!/usr/bin/env python3 | |
| import json | |
| from pathlib import Path | |
| LAWS_JSON_DIR = Path("laws_json") | |
| for js in LAWS_JSON_DIR.glob("*.json"): | |
| print(f"=== Examining {js.name} ===") | |
| with open(js, encoding="utf-8-sig") as f: | |
| data = json.load(f) | |
| print(f"Root data type: {type(data)}") | |
| print(f"Root data length: {len(data) if hasattr(data, '__len__') else 'N/A'}") | |
| if isinstance(data, list): | |
| print("It's a list. First 5 items:") | |
| for i, item in enumerate(data[:5]): | |
| print(f" [{i}] Type: {type(item)}") | |
| if isinstance(item, str): | |
| print(f" Content: {repr(item[:100])}...") | |
| elif isinstance(item, dict): | |
| print(f" Keys: {list(item.keys())}") | |
| if "LawName" in item: | |
| print(f" LawName: {item['LawName']}") | |
| else: | |
| print(f" Value: {item}") | |
| elif isinstance(data, dict): | |
| print("It's a dict. Keys:") | |
| for key in data.keys(): | |
| print(f" {key}: {type(data[key])}") | |
| if isinstance(data[key], list): | |
| print(f" (list length: {len(data[key])})") | |
| elif isinstance(data, str): | |
| print(f"It's a string. First 200 chars:") | |
| print(repr(data[:200])) | |
| print("\n" + "="*50 + "\n") |