0

I have a batch file scheduled to run a python script every morning. The script is supposed to append to a .csv file. However, some days no data is appended to the csv file which I believe is due to an error during execution of the script. Is there anything I can add to my batch file to save any error messages that cause the script to stop execution to a .txt file? Or is there a better way to do this within the python script instead? Right now in my batch file I just have

python "C:\filepath\pythonscript.py"

1 Answer 1

1

Append redirection to command line, as displayed bellow:

python "C:\filepath\pythonscript.py" 2>>log.txt

2>>log.txt statement redirect STDERR (errors printed by python interpreter) to a log file in APPEND mode (single > will switch to OVERWRITE mode). If you want to capture STDOUT too, change added apendix to >>log.txt 2>&1

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.