if arcpy.Exists("in_memory\\matchtable"): arcpy.Delete_management("in_memory\\matchtable") ## setup for the attachments input = r"H:\Documents\ArcGIS\Default.gdb\InstantValues" inputField = "InstantValues_staname" matchTable = arcpy.CreateTable_management("in_memory", "matchtable") matchField = "STATION" pathField = "Picture" arcpy.AddField_management(matchTable, matchField, "TEXT") arcpy.AddField_management(matchTable, pathField, "TEXT") picFolder = str(outfolder) ## check to see if matchtable exists and remove attachements if it does fields = ["STATION", "Picture"] cursor = arcpy.da.InsertCursor(matchTable, fields) ##go thru the picFolder of .png images to attach for file in os.listdir(picFolder): if str(file).find(".png") > -1: pos = int(str(file).find(".")) newfile = str(file)[0:pos] cursor.insertRow((newfile, file)) del cursor # the input feature class must first be GDB attachments enabled arcpy.EnableAttachments_management(input) # use the match table with the Add Attachments tool arcpy.AddAttachments_management(input, inputField, matchTable, matchField, pathField, picFolder) arcpy.AddMessage("Attachments enabled/created")
# Made your in memory table and add pertinent data table = arcpy.CreateTable_management("in_memory", tableName) arcpy.AddField_management(table, "ID", "LONG", 9) arcpy.AddField_management(table, "NAME", "TEXT") # Insert your data fields = ["ID","NAME"] with arcpy.da.InsertCursor(table,fields) as insertcursor: for row in dataToInsert: insertcursor.insertRow(row) # Some tools may require a table view ... arcpy.MakeTableView_management(table, "table_view") # Make sure to clean up your workspace, especially for larger batch processes arcpy.Delete_management(table) arcpy.Delete_management("table_view")
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.