koaning / calmcode-feedback

A repo to collect issues with calmcode.io
12 stars 0 forks source link

Add video(s) to rich on how to use progress bars #121

Open lalligood opened 2 years ago

lalligood commented 2 years ago

I have struggled with configuring progress bars in rich, particularly when it comes to having a list of local files that I am attempting to move/copy to another (local) location so that there is a progress bar indicator showing percentage of each file being moved/copied. (FWIW, the documentation for rich--and quite possibly rich's underlying code uses tqdm(?)--seems to fall short in this area too.)

I know the tqdm: files and descriptions video shows interacting with a list of files, but I do not believe this is the same as showing the percentage of a lengthy file operation has been completed.

Thank you for your consideration in creating a video that covers this topic!

koaning commented 2 years ago

There's a fun fact here: tqdm should have implemented a rich progress bar renderer. I should dive into that one as an extra video for the tqdm content.

Got a code example that you're having trouble with? It feels like something that does something like;

import pathlib
from rich.progress import track

# I'm assuming you want to copy only the csv files. 
local_files = pathlib.Path("folder").glob("**/*.csv")
for n in track(list(local_files), description="Processing..."):
    copy_csv_file(n)

should work.