I have a script which reclassifies a tif file, adds a new field to the tiff, and is supposed to parse the date from the filename and add it to the new date field. Everything works as it should, except parsing the date. When the script runs this line, python crashes, either runnig the script through ArcCatalog or python command line:

arcpy.ConvertTimeField_management("C:\Users\OuelletteMS\Desktop\Ice_Data_from_JohnIacozza\1978\wa_19780629_reclass.tif", 19780629, "yyyyMMdd", "Date")

This example is using variable values as they are assigned by the script (print the variables, copy/paste and add quotes). The full script is below.

I get no error messages, and commenting out this one line shows that everything else works. I got this line as a snippet after a successful run of the tool in ArcMap. What am I missing?

I'm using ArcGIS 10.1 SP1 and Python 2.7

import arcpy, os, sys
from arcpy import env

# Allow for file overwrite
arcpy.env.overwriteOutput = True

# Set the workspace directory 
path = "C:\Users\OuelletteMS\Desktop\Ice_Data_from_JohnIacozza"
env.workspace = path

# Get the list of the featureclasses in the workspace directory
listFCs = arcpy.ListFiles("wa_197806*.tif") 

# Loop through each file and perform the processing

for fc in listFCs:
    print str("processing " + fc)       # displays the file that is currently being handled

    shpname = str(fc)                   # converts filename to a string
    yearVal = shpname[3:7]              # year processed
    newName = shpname[0:11] + "_reclass.tif"    # name for reclassified raster
    newPath = path + "\\" + yearVal     # sets the path for the reclassified file
    outfile = newPath + "\\" + newName  # specifies reclassified raster path
    vf = "Value"                        # sets value field to be used
    strDate = shpname[3:11]             # extracts characters 3 through 11 from the file name

# Check to see if a directory for that year exists.  If not, make one
    except OSError:
        if not os.path.isdir(newPath):

# Reclassify raster
    arcpy.gp.Reclassify_sa(fc,vf,"1 5 1;6 99 0;NODATA 0",outfile,"NODATA")

# Adds and populates date field
    field2 = "Date"                     # Field for storing the date as a date
#    arcpy.ConvertTimeField_management(outfile, strDate, "yyyyMMdd", field2)

# Cleanup
del listFCs, fc, shpname, yearVal, newName, newPath, outfile, vf, strDate, field2

print "done"
  • Crashes == bad (I'd talk to Esri Support). You sure you have the right parameters though, for example, the 2nd parameter is a field name not a number.
    – DWynne
    May 2, 2015 at 0:53
  • I can reproduce with my own data. Looks related to the .tif input. I logged an issue myself.
    – DWynne
    May 2, 2015 at 1:20

1 Answer 1


Looks like your path at the beginning could be a problem. You should make it a 'raw' string or escape the slashes:

path = r"C:\Users\OuelletteMS\Desktop\Ice_Data_from_JohnIacozza"
path = "C:\\Users\\OuelletteMS\\Desktop\\Ice_Data_from_JohnIacozza"

My guess is the the List result is empty because the workspace doesn't exist.

  • The rest of the script runs successfully, and the List contains all the entries expected. Does the ConvertTimeField_management function require a different format than all the other functions? Just in case, I tried it escaping the slashes. Still crashes. May 1, 2015 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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