INNER CODE UNIT · Python
load_file
junruxiong/IncarnaMind · docs2db.py:75
def load_file(file_path):
"""Load a file and return its content as a Document object.
Args:
file_path (str): The path to the file.
Returns:
Document: The loaded document.
"""
ext = file_path.split(".")[-1]
if ext in loaders:
loader_type, args = loaders[ext]
loader = loader_type(file_path, **args)
doc = loader.load()
return doc