I have a CSV list containing paths to 800 TIFF files that I want to add to a mosaic dataset.
So using the Add Rasters to Mosaic Dataset tool, I need to create a loop which changes the input_path variable based on a list derived from the CSV. The CSV paths are formatted as follows -
D:\Docs111円\Name_of_Raster.tif
Looking at the documentation (https://pro.arcgis.com/en/pro-app/tool-reference/data-management/add-rasters-to-mosaic-dataset.htm), I've copied the stand alone script and converted the CSV to a Python list but am lost how to actually link the two together.
import arcpy,os,csv
arcpy.env.workspace = 'D:\'
md = 'D:\Map.gdb\Mosaic'
with open('D:\Mosaic_list.csv') as mosaic_csv:
reader = csv.reader(mosaic_csv, delimiter=' ', quotechar='|')
mosaic_list = list(reader)
print(mosaic_list)
for row in mosaic_list:
arcpy.AddRastersToMosaicDataset_management(in_mosaic_dataset = md, raster_type = 'Raster Dataset', input_path = row)
The above code results in - ERROR 000732: Input Data: Dataset Path does not exist or is not supported.
Is my approach correct or am I looking at this the wrong way?
1 Answer 1
Ok, thanks to Vince and ahmadhanb for the guidance. I was convinced the issue was with my lack of my python skills but I went back to square one and looked at my data after and found the first row of my CSV was 'pathname' and was the cause of the error.
Explore related questions
See similar questions with these tags.
arcpy.Exists()
during list assembly?