0

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:\Docs\111\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?

  • 3
    How the paths are organized inside the CSV file? It is better to add a sample of the CSV file into your question. – ahmadhanb Sep 18 '19 at 6:53
  • 1
    Have you tried testing on arcpy.Exists() during list assembly? – Vince Sep 18 '19 at 10:35
0

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.

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.