title: Submitting a Directory to Parse sidebarTitle: Can I submit an entire directory to parse?

Submitting a directory for document extraction

You can also submit a directory of files for document extraction using the Tensorlake Data Loader API. And since the loader returns an array of documents, you can simply iterate through each of the documents, uploading each one to Tensorlake through the Files API, storing the file_id as you upload into an array. Then, you can do the same with the Parse API, parsing each document stored in the file_id arracy you just made with doc_ai.parse, saving the job_id into an array. The job_id array can then be iterated through to get the results of each job.
from tensorlake.data_loaders import LocalDirectoryLoader
from tensorlake.documentai import DocumentAI

loader = LocalDirectoryLoader("/path/to/files", file_extensions=[".pdf"])
loaded_files = loader.load()

doc_ai = DocumentAI(api_key="xxxx")

file_ids = []
for file in loaded_files:
    file_id = doc_ai.upload(file)
    file_ids.append(file_id)

jobs = []
for file_id in file_ids:
    job_id = doc_ai.parse(file_id)
    jobs.append(job_id)