1
1
I have a Python script that uses csv.writer
to create a csv file. This works fine when I run it from the command line, but no file is created when I run the script using Windows Task Scheduler. The only thing I can think of is that I'm not running my computer as admin (because it's a work computer), but why would it let me do this on command line but not in Scheduler? The rest of the script runs with Scheduler, just not the csv file saving part.
Try to change the task's user under which it runs. Also, you haven't mentioned or tagged what Windows / OS you're using. – JasonXA – 2015-04-17T15:01:01.120
I can't change the user because I am on a work computer. I'm using Windows 7. – Abbie – 2015-04-17T15:52:39.997
@Abbie let me rewrite your script to powershell or WSH) – STTR – 2015-04-17T17:41:00.423
No Abbie, when setting up the task, in the properties there's a user under which it can run, try to change that. It's under the General tab as posted below in the screenshot. If you run as a limited user, then the write operations might fail just because there are no relevant privileges for the operation. Try to run it under your user and make sure the csv file is written to a location where you're allowed to write. – JasonXA – 2015-04-18T10:57:15.113
I was already running it under my user profile. What I don't understand is that there aren't privilege problems writing the csv file when I run this script myself from the command line but, when I use Task Scheduler, it doesn't write the csv file. – Abbie – 2015-04-20T08:10:30.263
What is the command you are using in python to write the .csv file? – law10 – 2015-11-24T21:07:44.813
@law10 I'm opening the file using
report = open(filename, 'w')
and closing it at the end usingreport.close()
– Abbie – 2015-11-25T08:50:21.230