This has been something I've been meaning to write a post about for a while, and I finally found myself with a free moment to document the process!
I recently needed to develop a python script that I could utilize for checking a specific file directory for changes. By "changes", I mean any additions, deletions, or modifications to the files located within a specific directory. For this exercise, I was not concerned with the type of change that was occurring, but only the time/date the change occurred.
Below is the script I came up with for this process, which reports on the 'Date Modified' column for a specific directory:
#Quick and dirty method for checking last modified date
#for a folder or file path
#Tim Hohn 11/15/2017
#import modules
import os.path, time
#print date modified for specified file directory
print("Export_Test Folder - Last modified: %s" % time.ctime(os.path.getmtime("H:\Desktop\Test\Export_Test")))
Running this script once every morning has been helpful towards keeping up with changes to a specific directory, especially in responding to new documents that have been uploaded that may require immediate attention. Setting the script to run at a specific time through Task Scheduler, further assists the process and eliminates the need for me to remember to check the directory for changes every day.
Alternatively, in my research for the above process I came across a "watchdog" script that will specify the type of change (added or removed) that occurred.
#Watchdog designed to alert the user when files have been
#added, removed or updated within a directory
#Original Source Here: http://timgolden.me.uk/python/
#win32_how_do_i/watch_directory_for_changes.html
#Import Modules
import os, time
#Set Path to Watch
path_to_watch = "H:\Desktop\Test\Export_Test"
before = dict ([(f, None) for f in os.listdir (path_to_watch)])
#Print Current Time
print time.asctime( time.localtime(time.time()) )
#Watch for changes to the directory specified in path_to_watch
while 1:
time.sleep (0.5)
after = dict ([(f, None) for f in os.listdir (path_to_watch)])
added = [f for f in after if not f in before]
removed = [f for f in before if not f in after]
if added: print "Added: ", ", ".join (added)
if removed: print "Removed: ", ", ".join (removed)
before = after
So there you have it! A couple of different methods for checking a directory for changes within python.
Ideas for next steps to make these scripts more useful:
1. Generate a text report of changes daily
2. E-mail report to personal e-mail daily
3. Run overnight and have report ready and sent to inbox in A.M.
Showing posts with label task. Show all posts
Showing posts with label task. Show all posts
Tuesday, November 28, 2017
Wednesday, August 23, 2017
Using Microsoft Access to Track Tasks
Earlier this year I experienced an increase in workload, as I took on a more central roll in developing GIS solutions and project support within my company.
To deal with the increasing number of requests for GIS support I was receiving, I wanted to set up a GIS Task Tracker database/spreadsheet that I could use to easily input and track requests. In addition, I would have a number of other GIS staff assisting with the project, so I felt task management would need to take center stage if the project was going to continue running smoothly.
I began with a template in Excel, but it quickly became clear that this approach wouldn't work....our spreadsheet became riddled with errors and many staff were forgetting to enter tasks. I decided to scrap my original Excel document and use an Access database, in part because of a number of benefits I saw:
1. Access could be easily linked to our Outlook accounts.
2. Tasks could be directly e-mailed to GIS staff through this Outlook connection.
3. A task form could be utilized, for easily entering accurate task information.
4. GIS staff could quickly and easily communicate with project staff with regard to time frames and workload issues.
5. Attachments could be added to each individual request.
6. Finally, Excel is ultimately a tool for small scale data analysis. It became clear that Access was the right tool for this complex data management/storage task.....perfect for this exercise.
In my research, I was fortunate to find an (almost) perfect template developed by Microsoft here:
https://support.office.com/en-us/article/Use-the-Task-Management-Access-Database-template-50376839-8cc6-4d29-ac1b-b9fce69605f8
The original template wouldn't need much editing on my end, just a few extra fields and changes to the primary form used for adding new tasks:
Adding tasks in the table view was simplified with the creation of an entry form:
With the Task Tracker in place, my workload became much more manageable and allowed me to generate queries and reports detailing the influx of recent requests. I would highly recommend this database template for anyone looking to manage GIS requests within a medium or even large GIS work group.
To deal with the increasing number of requests for GIS support I was receiving, I wanted to set up a GIS Task Tracker database/spreadsheet that I could use to easily input and track requests. In addition, I would have a number of other GIS staff assisting with the project, so I felt task management would need to take center stage if the project was going to continue running smoothly.
I began with a template in Excel, but it quickly became clear that this approach wouldn't work....our spreadsheet became riddled with errors and many staff were forgetting to enter tasks. I decided to scrap my original Excel document and use an Access database, in part because of a number of benefits I saw:
1. Access could be easily linked to our Outlook accounts.
2. Tasks could be directly e-mailed to GIS staff through this Outlook connection.
3. A task form could be utilized, for easily entering accurate task information.
4. GIS staff could quickly and easily communicate with project staff with regard to time frames and workload issues.
5. Attachments could be added to each individual request.
6. Finally, Excel is ultimately a tool for small scale data analysis. It became clear that Access was the right tool for this complex data management/storage task.....perfect for this exercise.
In my research, I was fortunate to find an (almost) perfect template developed by Microsoft here:
https://support.office.com/en-us/article/Use-the-Task-Management-Access-Database-template-50376839-8cc6-4d29-ac1b-b9fce69605f8
The original template wouldn't need much editing on my end, just a few extra fields and changes to the primary form used for adding new tasks:
| View of the task tracker in Access |
Adding tasks in the table view was simplified with the creation of an entry form:
| View of the Entry Form |
With the Task Tracker in place, my workload became much more manageable and allowed me to generate queries and reports detailing the influx of recent requests. I would highly recommend this database template for anyone looking to manage GIS requests within a medium or even large GIS work group.
Subscribe to:
Posts (Atom)
Work in Progress - Disputed Areas Map
I started this project as a fun change of pace from my normal GIS day-to-day, and as a way of brushing up on my cartography skills. For me,...
-
Since 2013, I have been contributing to various projects with the Humanitarian OpenStreetMap Team ( http://tasks.hotosm.org/ ). While my co...
-
This is a fairly simple process that I came across when toying around with some data from my Fantasy Football league. I already had an e...
-
Earlier this year I experienced an increase in workload, as I took on a more central roll in developing GIS solutions and project support wi...