Arcpy strip '{ and ]' from list return

المشرف العام

Administrator
طاقم الإدارة
I have a static list that I would like to pull values from and use in a query. I can populate the list dynamically from the data but the set is quite large and I think having a static list from a csv would increase performatance. I cannot get Arc to accept the return from the input to the select by attribute clause.

class ComboBoxClass1(object): """Implementation for addin2_addin.combobox (ComboBox)""" def __init__(self): self.editable = True self.enabled = True self.dropdownWidth = 'W' * 16 self.width = 'W' * 16 mxd = arcpy.mapping.MapDocument("CURRENT") self.mxd = arcpy.mapping.MapDocument("CURRENT") self.df = arcpy.mapping.ListDataFrames(mxd)[0] def onSelChange(self, selection): selection = str(selection).replace("'[",'').replace("]'",'') layer = arcpy.mapping.ListLayers(self.mxd, "block_cards", self.df)[0] a = arcpy.SelectLayerByAttribute_management(layer, "NEW_SELECTION", "town = '{}'".format(selection)) self.df.extent = layer.getSelectedExtent() arcpy.RefreshActiveView() def onFocus(self, focused): fldName = "town" with open(r'towns_table.csv', 'rb') as f: reader = csv.reader(f) your_list = list(reader) layer = arcpy.mapping.ListLayers(self.mxd, "block_cards", self.df)[0] arcpy.SelectLayerByAttribute_management(layer, "CLEAR_SELECTION") self.items = sorted(list(your_list))I have tried several things to strip the brackets from the return (in python everything comes back '[denver]') with no luck. i think thats the sticking point but i could be off on that.

any help would be great!



أكثر...
 
أعلى