TGViewer
Zen of Python Zen of Python @zen_of_python · 18.8K subscribers
Post #2970 5.07K
«Слушатель» новых файлов в директории

Небольшая Python-библиотека, которая позволяет отслеживать появление новых элементов в папке. Предназначена для обработки сразу после создания: например, подгрузка из файлов.csv в базу данных сразу после создания.

import python-directory-watch

for new_file_path in listen(Path("test_dir"), pattern = "*.txt"):

try:
#DO STUFF with new_file_path
print(f"{new_file_path}")

except Exception:
# For use cases such as writing to database often exceptions
# should be handled without raising exceptions and stopping python process.
traceback.print_exc()

Документация

#библиотека
GitHub GitHub - noahridge/python-directory-watch: Simple Python library to watch a directory for new files Simple Python library to watch a directory for new files - GitHub - noahridge/python-directory-watch: Simple Python library to watch a directory for new files
  • 👍 6
  • ❤ 1
  • 👏 1
  • 🍌 1
More from @zen_of_python
  1. Oct 8, 2026Почему цикл внутри теста скрывает часть ошибок Тест перебирает десять входов и проверяет р…
  2. Oct 8, 2026Как выполнять CPU-задачи в отдельных интерпретаторах Python В Python 3.14 InterpreterPoolE…
  3. Oct 8, 2026Как отличить отсутствие аргумента от None в Python Если None — допустимое значение настрой…
  4. Oct 7, 2026security.txt в Django: контакт для сообщений об уязвимостях Исследователь нашёл уязвимость…
  5. Oct 6, 2026Как открывать ссылки Django-сайта в приложениях Apple и Android Для этого нужна двусторонн…
  6. Oct 6, 2026Как собрать Rust-проект с Python-модулем и отдельной программой В пошаговом примере кальку…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →