Spaces:
Runtime error
Runtime error
Download utils/write_to_json.py from beautiful-code/ai_workflows: direct link, hf CLI and curl.
- Browser
- Download file 346 Bytes
-
https://huggingface.co/spaces/beautiful-code/ai_workflows/resolve/refs%2Fpr%2F1/utils/write_to_json.py
- Command line
-
hf download hf://spaces/beautiful-code/ai_workflows@refs/pr/1/utils/write_to_json.py
-
curl -L -o write_to_json.py https://huggingface.co/spaces/beautiful-code/ai_workflows/resolve/refs%2Fpr%2F1/utils/write_to_json.py
346 Bytes
| import json | |
| def write_dict_to_json(data, filename="data.json", indent=4): | |
| try: | |
| with open(filename, 'w') as json_file: | |
| json.dump(data, json_file, indent=indent) | |
| print(f"Successfully wrote dictionary to {filename}") | |
| except (IOError, json.JSONDecodeError) as e: | |
| print(f"Error writing to JSON file: {e}") | |