# ArcGIS Server GP Service: How to create a txt file or rename a dbf to txt in the “%SCRATCHWORKSPACE%”

My end goal is to get an excel (I'll probably just settle for .csv) file loaded from a silverlight app into my "%SCRATCHWORKSPACE%" for my gp service. I will be linear referencing the data onto a polyline.

I have silverlight reading the csv file's contents and packing it into a string to send over to ArcGIS Server.

Then I want to write this data to a csv file in the "%SCRATCHWORKSPACE%". But I don't seem to be able to use any standard python code to hit the "%SCRATCHWORKSPACE%".

Any thoughts or critiques?

-

Set an input to your gp service to be the %scratchworkspace% - this should get resolved by ArcGIS Server into a actual directory path on disk that (assuming the SOC account has access to the folders) you should be able to write to no worries. It will end up in the arcgisjobs folder, in a subfolder under the name of the service, and then under another subfolder that is created by ArcGIS Server on a random text string. e.g.:

C:\arcgisserver\arcgisjobs\toolbox\model\j5f4eb1370ded4e8e99a17519c0989850


Last tip is that this doesn't get cleaned up automatically, so you'll have to set that up yourself.

Hope this helps!

-
I have no issues writing to the the job folder j5f4eb1370ded4e8e99a17519c0989850\scratch\ folder with arcpy methods but I can't do os.rename(src,dst). I get an error saying the directory is not found. –  Justin Apr 18 '12 at 12:51

arcpy.env.scratchWorkspace yields

C:\Users\ARCGIS~\AppData\Local\Temp\geoprocessing\model_gpserver\j7560bf9fcf9844f7a4736d36ea123456\scratch

Which allowed my to use non-arcpy methods targeting the scratch workspace of a gp service job request.

-