Reading next row of *.txt column inside ArcPy for loop for batch process?

المشرف العام

Administrator
طاقم الإدارة
I'm not sure how to approach this problem with python, but in plain english, I'd like to rename rasters with the names given in the *.txt file (see screenshot) and concatenate the basename given by the text file with the original file extension. For example I would like snowdepthN0001.tif to be renamed to 12-Jul_02.tif

So far to check my progress, I've only been able to print single letters or characters from the text file per row rather than the all the characters within each row.

Anyone see what I'm missing?

import osimport arcpyfrom arcpy import envRASTER_DIR = r"C:\VMshared\small_example_valley8\SDpartINTRaster"env.workspace = RASTER_DIRdate_file = open("timetest.txt", "r")for raster in arcpy.ListRasters(): fileName,fileExtension = os.path.splitext(raster) for row in date_file.read(): print row fileNameParts = row fileNameParts = fileName.split('_') compactFileName = row + fileExtension arcpy.Rename_management(raster,compactFileName)date_file.close()


Here's what the raster names look like (there are 90 of them).





أكثر...
 
أعلى