Reputation: 1
I am new to python. I have this code:
import arcpy
from arcpy import env
import os
from arcpy.sa import *
# Set the current workspace
env.workspace = "\C:\Users\kfi179\Desktop\rgccsdaily2013"
outWorkspace = "C:\Users\kfi179\Desktop\Texas)"
dataType = "FLOAT"
#Check out the Arcgis Spatial Anaylst extension licence
arcpy.CheckOutExtension("Spatial")
# Get a list of ascii
for file in arcpy.ListFiles("*.txt"):
#Print raster list
print file
outputraster = file[0:12] + ".tif"
#Save TIF
#outRaster.save(output)
arcpy.ASCIIToRaster_conversion(file,outputraster,dataType)
and keep getting this error:
Traceback (most recent call last):
File "C:\Users\kfi179\Desktop\AsciiToRaster.py", line 17, in <module>
for file in arcpy.ListFiles("*.txt"):
TypeError: 'NoneType' object is not iterable
What do I need to do to fix it?
Thanks!
Upvotes: 0
Views: 754
Reputation: 7603
It seems arcpy.ListFiles("*.txt")
return None instead of a file list. I noticed your env is set to "\C:\Users\kfi179\Desktop\rgccsdaily2013"
. I think you have a backslash at the beginning which make the file list fail. Also, backslashes need to be escaped. Might be better to use forward slashes
"C:/Users/kfi179/Desktop/rgccsdaily2013"
Upvotes: 2