Spaces:
Running
Running
File size: 842 Bytes
a532053 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import json
def load_json_data(file_name: str, file_path: str) -> dict:
"""
Loads JSON data from a file.
Args:
file_name (str): The name of the JSON file.
file_path (str): The path to the directory containing the file.
Returns:
dict: The content of the JSON file as a dictionary.
"""
file_path = f"{file_path}/{file_name}"
with open(file_path, "r") as file:
return json.load(file)
def sanitize_input(input: str) -> str:
"""
Sanitizes a string by stripping, lower casing, and replacing whitespace and hyphens with underscores.
Args:
input (str): The string to be sanitized.
Returns:
str: The sanitized string.
"""
if input is None or input == "":
return ""
return input.strip().lower().replace(" ", "_").replace("-", "_")
|