rowMembers = arcpy.SearchCursor(fc6,qTeam) lMembers = [] for z in rowMembers: mName = z.getValue("Name") lMembers.append(mName)
for i in lMembers: wMembers = lMembers arcpy.AddMessage(lMembers) arcpy.AddMessage(wMembers)
Solved! Go to Solution.
Yes the names populate correctly. The reason the list 'could' be empty is if there are no people in that Team yet. The team name woudl exist in the teams table by has no members at this time, so i need to account for that.
I'm very new to Python (like a week) and I'm unaware of dictionaries, which is why I didn't use them 🙂 Thanks for the other tips.
[ATTACH=CONFIG]16519[/ATTACH]
I've attached the run screen as a screenshot
for item in lMembers: wMembers = item arcpy.AddMessage(item)
item = None
item = None for item in lMembers: wMembers+item_number = item wMewmberName+Value_of_lMember
members_dict = {} for index,name in enumerate(lMembers,1): members_dict[index] = name
txt.write("<</T(FDF Field Name)/V(" + str(arcpy variable name) + ")>>\n") [\code] I have potentially 9 team members, but not always. I may have none or some, not always 9. I'm trying to write these values in a loop. So something like this Loop through the members list create a variable for each item in the list populate that variable with the value from the list write that variableto the FDF file using txt.write so the loop would actually contain the txt.writefor item in lMembers: FDF_Field_Name = FDF_Field_Name+item FDF_Field_Name+item = lmembers+string_value txt.write("<</T(FDF_Field_Name)/V(" + str(FDF_Field_Name+item) + ")>>\n") arcpy.AddMessage(item)
something like that, probably clear as mud now ;)
Cheers
Sorry for being unclear.
As I mentioned, ultimately I'm writing values to an FDF file, which will be used in conjunction with a PDF template. The PDF contains fields for each Member, there can be up to 9 members. The fields are named Member1, Member2, etc. through Member9.
The line of code that writes the values out is this. Using the field name in the PDF/FDF, and the data from the scripttxt.write("<</T(FDF Field Name)/V(" + str(arcpy variable name) + ")>>\n") [\code] I have potentially 9 team members, but not always. I may have none or some, not always 9. I'm trying to write these values in a loop. So something like this Loop through the members list create a variable for each item in the list populate that variable with the value from the list write that variableto the FDF file using txt.write so the loop would actually contain the txt.writefor item in lMembers: FDF_Field_Name = FDF_Field_Name+item FDF_Field_Name+item = lmembers+string_value txt.write("<</T(FDF_Field_Name)/V(" + str(FDF_Field_Name+item) + ")>>\n") arcpy.AddMessage(item)
something like that, probably clear as mud now ;)
Cheers
FDF_Field_Name = "Member1" item = "Joe"
FDF_Field_Name = "Member" for index,item in enumerate(lMembers,1): name_field = "{0}{1}".format(FDF_Field_Name,index) txt.write("<</T({0})/V({0}{1})>>\n".format(name_field,item)) arcpy.AddMessage(item)
lMembers = ["Joe","Sue","Anne"]
name_field = "Member1" item = "Joe"