Spaces:
Running
Running
File size: 496 Bytes
3a3b216 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from graphgen.models import CsvReader, JsonlReader, JsonReader, TxtReader
_MAPPING = {
"jsonl": JsonlReader,
"json": JsonReader,
"txt": TxtReader,
"csv": CsvReader,
}
def read_files(file_path: str):
suffix = file_path.split(".")[-1]
if suffix in _MAPPING:
reader = _MAPPING[suffix]()
else:
raise ValueError(
f"Unsupported file format: {suffix}. Supported formats are: {list(_MAPPING.keys())}"
)
return reader.read(file_path)
|