Geoprocessing with ArcGIS Server 10.1

1712
4
08-27-2013 02:33 PM
DougCollins
Occasional Contributor
I'm new to Geoprocessing, but would like to determine if I have a model created in ArcGIS Desktop Model Builder, can I convert that model to a Python Script for publishing to ArcGIS Server? 

I would like to convert it to Python because I want to add a couple of things that don't seem to be possible in Model Builder, such as write some output to a CSV file or even a text file.  The Model Builder only seems to support GeoDatabases for output.  Is there a way to output data to a CSV file once published to ArcGIS Server?

Thanks,
Charlie
0 Kudos
4 Replies
JakeSkinner
Esri Esteemed Contributor
Hi Charles,

You can export your model to a python script by clicking on the Model menu within ModelBuilder > Export > To Python Script.  Once the script is export and you add your additional code, you can add it back to the toolbox by right-clicking on the toolbox > Add > Script.  Next, run the script by double-clicking on it.  Once it completes successfully, open up the Results window (Geoprocessing menu > Results).  Under Current Session, right-click on the completed script > Share As > Geoprocessing Service.
0 Kudos
DougCollins
Occasional Contributor
Jake,
Thanks for the information on converting to python and publishing to ArcGIS Server.

Once I have the model in python, is it possible to add some code to the python script that will write some data out to a CSV file?  Would it then be possible to follow your instructions on publishing to ArcGIS Server, and have this run as a Geoprocessing Service?

Thank you,
Charlie
0 Kudos
JakeSkinner
Esri Esteemed Contributor
You can use the Table to Table conversion tool to create a .dbf file.  Then you can use python's os.rename() method to rename the file to a .csv file.  Ex:

os.rename(r"C:\Temp\Gages.dbf", r"C:\Temp\Gages.csv")
0 Kudos
KevinHibma
Esri Regular Contributor
I haven't tried Jake's method, but there are tools here that write to CSV you could try as well
http://www.arcgis.com/home/item.html?id=f3d91b8f852042e289e09a7ec8342431
0 Kudos