Przeszukaj forum
Pokazuję wyniki dla tagów 'python watchdog'.
Znaleziono 1 wynik
-
hej, chcę monitorować folder pod katem nowo pojawiających się w nim plików csv, problem w tym że program raz działa a innym razem wywala błąd :"PermissionError: [Errno 13] Permission denied: ". Miał ktoś już z tym do czynienia? import csv import time from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler class MyHandler(FileSystemEventHandler😞 def on_created(self, event😞 if event.is_directory: return elif event.event_type == 'created': process_new_file(event.src_path) def process_new_file(file_path😞 with open(file_path) as csv_file: reader = csv.DictReader(csv_file) desired_key_part = 'AF;PS6 Lastdruck' for entry in reader: value = entry['$$ VALMET AUTOMOTIVE SP. Z O.O.'] if value.startswith(desired_key_part😞 parts = value.split(';') num_values = [float(part) for part in parts[3:6]] round_values = [round(values,2) for values in num_values] first_numeric_value, second_numeric_value, third_numeric_value = round_values istwert_values_for_stat = [] istwert_values_for_stat.append(first_numeric_value) print(istwert_values_for_stat) if __name__ == "__main__": folder_to_monitor = r"C:\Users\User\PycharmProjects\pythonProject114" event_handler = MyHandler() observer = Observer() observer.schedule(event_handler, path=folder_to_monitor, recursive=False) observer.start() try: while True: time.sleep(1) except KeyboardInterrupt: observer.stop() observer.join()