Last active
October 2, 2023 11:10
-
-
Save pradishb/f197c503487cef929a3edb70e8a4b83e to your computer and use it in GitHub Desktop.
Convert all xlsx files in folder to pdf using libre office in threads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import concurrent.futures | |
from tqdm import tqdm | |
from glob import glob | |
def process_file(file_path): | |
os.system(f'"C:\Program Files\LibreOffice\program\swriter.exe" --headless --convert-to pdf {file_path}') | |
def process_files_with_threads(): | |
files = list(glob('*.xlsx')) | |
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor: | |
with tqdm(total=len(files)) as pbar: | |
futures = [executor.submit(process_file, file_path) for file_path in files] | |
for future in concurrent.futures.as_completed(futures): | |
pbar.update(1) | |
process_files_with_threads() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment