I am trying to convert more than 100 ascii files to raster using python code. All the lines (except Last two) in my code presented below is successfully converting Ascii to tif format in the working directory. However, I want to save the new TIF files in a separate directory. Therefore, the last two lines in my code, I am trying to save in a new directory. But, I am getting an error:

"Traceback (most recent call last):
  File "C:\Subhasis\Project-Biological_monitoring\R_SAGA\Raster_data\ASCII_Raster.py", line 22, in <module>
AttributeError: 'Result' object has no attribute 'save'"


import arcpy, os
from arcpy import env
from arcpy.sa import *

#To overwrite output
arcpy.env.overwriteOutput = True

#set work environment
env.workspace = "C:/Subhasis/Project-Biological_monitoring/R_SAGA/Raster_data"



# Check out the ArcGIS Spatial Analyst extension license

for file in arcpy.ListFiles("*.asc"):
    outputraster = file.strip(".asc")+ ".tif"
  • Did you ever figure this out? I'm having a similar problem with "ExtractByMask" even though the syntax is exactly like that in the code sample from the help documentation. May 31, 2016 at 12:37

1 Answer 1


Without testing, I think you should change:




You are seeing your error in the original code because Ascii_raster is set to a result object and that does not have a save method.

  • Thank you for your advice. I changed the code the way you told me in your answer. It is creating the TIF files in the current working directory, However, I want to save the new TIF files in a separate directory.
    – Dev
    Apr 14, 2015 at 21:18
  • 1
    The code I provided should be saving into outWorkspace i.e. "C:/Subhasis/Project-Biological_monitoring/R_SAGA/Raster_data/Final"
    – PolyGeo
    Apr 14, 2015 at 21:34
  • 1
    ASCIIToRaster_conversion doesn't create a Raster object, it creates a file, in a similar manner to Clip_analysis, CopyFeatures_management etc.. if you want it to be a raster you'll need to open it Ascii_raster=arcpy.Raster(outname) but that sort of defeats the purpose of trying to save it because it's already there. Apr 15, 2015 at 0:49
  • @PolyGeo, Sorry to bother you again. Yes, I tried the code you told me and got this error below:Traceback (most recent call last): File "C:\Subhasis\Project-Biological_monitoring\R_SAGA\Raster_data\ASCII_Raster.py", line 21, in <module> arcpy.ASCIIToRaster_conversion(file,outname,dataType) File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\conversion.py", line 2217, in ASCIIToRaster raise e ExecuteError: ERROR 010158: Unable to open file AN0008~1.ASC. ERROR 010067: Error in executing grid expression. Failed to execute (ASCIIToRaster).
    – Dev
    Apr 15, 2015 at 13:54
  • I think you should research/ask that separately. It looks like the type of error you might see running the tool from its dialog i.e. not an ArcPy problem.
    – PolyGeo
    Apr 15, 2015 at 13:57

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.