Add source example files
This commit is contained in:
21
source/multithreading/batch_info.py
Normal file
21
source/multithreading/batch_info.py
Normal file
@ -0,0 +1,21 @@
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from pathlib import Path
|
||||
import pandas as pd
|
||||
|
||||
|
||||
def process_file(name: Path):
|
||||
"""Afficher les informations concernant un fichier .xlsx."""
|
||||
dataframe = pd.read_excel(name)
|
||||
print(f"{name.name:>30} : {len(dataframe)} enregistrements.")
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Parcourir les fichiers du projet à la recherche de fichiers XLSX
|
||||
# Définir le chemin de départ à celui du projet (contenant le fichier requirements.txt)
|
||||
path = Path(__file__)
|
||||
while not (path / "requirements.txt").exists():
|
||||
path = path.parent
|
||||
# Parcourir tous les fichiers .xlsx récursivement
|
||||
executor = ThreadPoolExecutor(max_workers=8)
|
||||
futures = []
|
||||
for result in path.rglob("*.xlsx"):
|
||||
futures.append(executor.submit(process_file, result))
|
BIN
source/multithreading/world-cities.xlsx
Normal file
BIN
source/multithreading/world-cities.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user