Python Forum
Watch new files and modify it - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Watch new files and modify it (/thread-16943.html)



Watch new files and modify it - Macha - Mar-21-2019

Hello everyone,

I'm looking for some help on one of my project. I will try to describ my problem as best as I can.

I have a .txt files generated by a software every 50-60sec around. The new file replaces the last one, the name stay the same.
I want to open that files when he is written, modify some line et save to another folder.

My problem : I don't how to watch a specific folder to see new files. Can you help me on it?

I have search on google without success, maybe I didn't have the right key work for this.

Thank you all of you for your help, Big Grin Big Grin


RE: Watch new files and modify it - buran - Mar-21-2019

have a look at watchdog


RE: Watch new files and modify it - hshivaraj - Mar-27-2019

There's also pywatch you can use. Wrapper around linux watch command.


RE: Watch new files and modify it - metulburr - Mar-27-2019

You could use git, make a commit, then come back later and compare and contrast the difference with diff argument. The python standard library difflib is similar if you want to programmatically do it.