Tuesday, 30 January 2018

arcpy - Getting print statements in Python script to print through a batch file


I'm starting to learn Python and batch files. I have a Python script which selects data by location and exports the selection to a new feature class. The script runs just fine - included in this script I have the following lines:


matchCount = int(arcpy.GetCount_management(featureLayer).getOutput(0))

print str(matchCount) + " rows exported"

When I run this script in PythonWin the print statement above is produced in the Interactive Window. When I run this script through a batch file the print statement isn't produced. At the end of my batch file I have written PAUSE so the screen doesn't disappear after running my script. Anyone have ideas on how to produce my print statement in command line?



Answer



Can you show us the contents of your batch file please?



(BTW, recommended practice is to use arcpy.AddMessage() rather than print, for portability between command line/batch files and ArcMap. But print is fine if you don't want your message to display inside ArcMap.)


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...