0

I am trying to automate excel tasks in Python using Pandas. I get 3 input data files which I intend to store in a folder and run python script which will read the python script do the data transformation and write an output excel file.

My question is how do I Monitor the folder and run the python script if there is a file there. For example if the excel input files are copy pasted in a defined empty folder1 it should trigger the python script automatically and generate the output file in a defined empty folder2.

I have already made a python script which does the data manipulation by reading the input files and generating the output excel file. How do I go about the automation which triggers the python script?

PS: I work on mac laptop any reference compatible with iOS would be greatly appreciated.

  • Use [`glob`](https://docs.python.org/3/library/glob.html) or [`os.listdir`](https://docs.python.org/3.6/library/os.html#os.listdir) to iterate over files in a directory – Jab Aug 01 '19 at 19:41
  • Are you asking about scheduling the python file to run from a Mac? – chucklukowski Aug 01 '19 at 19:45
  • will the script be running 24/7 from a server? – Umar.H Aug 01 '19 at 19:47
  • How do I monitor an empty folder for my input excel raw data extracts and then trigger a data transformation python script which will give me an output excel file in a macbook pro laptop. The script wont be running 24/7. Only how do I trigger it when the files are copy pasted in the folder – Labdhi Ghelani Aug 01 '19 at 19:47
  • 1
    Related: [Watch Filesystem in Real Time on OS X and Ubuntu](https://superuser.com/questions/431624/watch-filesystem-in-real-time-on-os-x-and-ubuntu) or [Monitor a Folder OSX for file changes then run a bash script](https://superuser.com/q/445907/14566). – unutbu Aug 01 '19 at 19:54
  • 2
    There is also this SO question: [How do I watch a file for changes?](https://stackoverflow.com/q/182197/190597). The accepted answer is Windows-specific, but there are other answers (such as [watchdog](http://packages.python.org/watchdog/)) which are cross-platform. – unutbu Aug 01 '19 at 19:58

0 Answers0