Spaces:
Runtime error
Runtime error
Download schema_miner/utils.py from SciKnowOrg/schema-miner: direct link, hf CLI and curl.
- Browser
- Download file 677 Bytes
-
https://huggingface.co/spaces/SciKnowOrg/schema-miner/resolve/main/schema_miner/utils.py
- Command line
-
hf download hf://spaces/SciKnowOrg/schema-miner/schema_miner/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/SciKnowOrg/schema-miner/resolve/main/schema_miner/utils.py
677 Bytes
| import json | |
| def read_json_file(filepath: str, encoding: str = 'utf-8'): | |
| """ | |
| Reads the JSON file and return it's content | |
| :param str file_path: The path to the JSON file | |
| :param str encoding: The encoder to use for reading the file | |
| :returns json_dict: The JSON file content | |
| """ | |
| try: | |
| with open(filepath, 'r', encoding=encoding) as f: | |
| data = json.load(f) | |
| return data | |
| except json.JSONDecodeError: | |
| print('Cannot parse JSON file: {}'.format(filepath)) | |
| except FileNotFoundError: | |
| print('File Not Found: {}'.format(filepath)) | |
| except Exception as e: | |
| print('Exception Occured: {}'.format(e)) |