if myList contains only 1 object ie len(myList) == 1 then join, split etc indeed any list function will interate through the individual components.
So just check first if len(myList) > 1, before using ",".join(myList)
Ahmed,
Thanks for the guidance here. I am looking to achieve the same goal with the script results separated by a comma. When I use the syntax;
myList = reprojectedFCs
x = ", ".join(myList)
arcpy.AddMessage("Projected " + str(x))
I end up with commas before and after every single letter - instead of after each feature class. I am new to scripting, any idea what I am doing wrong here?
Thanks,
Evan
import arcpy, os from arcpy import env env.workspace = r"C:\temp\python\test.gdb" # Create an empty list list = [] # Create a text file output = open(r"C:\temp\python\list.txt", "w") lstFCs = arcpy.ListFeatureClasses("*") for fc in lstFCs: list.append(fc) # write each feature class to the text file for n in list: output.write(n + " ") # read the text file and add commas output = open(r"C:\temp\python\list.txt", "r") s = output.read() s = s.rstrip() s = s.replace(" ", ", ") arcpy.AddMessage(s) # close and delete the text file output.close() os.remove(r"C:\temp\python\list.txt")
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.