How do I fix a unicoded(?) list

20 views
Skip to first unread message

Lew

unread,
Oct 31, 2012, 2:49:53 PM10/31/12
to Python - ARCGIS geoprocessing
Hi Pythoneers,


I used the code below to make a list of values in an attribute. It
created what I think is a unicoded list, as below. When I attempt to
strip the "u" prefix from the list, the line -- print item --
prints the item without the 'u' prefix, but newList keeps it


fireNumList = set([row.getValue(fldName) for row in
arcpy.SearchCursor(outFeatures3)])

newList = []
for item in fireNumList:
#newName = item.strip('u')
newList.append(item.strip('u'))
print item

print newList


[u'R20133', u'N50296', u'G90403', u'G90249', u'K20972', u'N20626',
u'G90245', u'G70061', u'G90240', u'G90369', u'K60589', u'C20210']

Thanks for you help!
Lew.

Lew

unread,
Oct 31, 2012, 3:00:10 PM10/31/12
to Python - ARCGIS geoprocessing
Hey Pythoneers,

I found the answer by searching "unicode" on Geopython. Fran
Tarkenton provided an answer in one of his previous posts.

The solution was to simply convert the unicode string to a regular
string as follows:

newList.append(str(item))


http://groups.google.com/group/geopython/browse_thread/thread/3f5a51e25548f75b/4318f59ab073ebfc?lnk=gst&q=unicode#4318f59ab073ebfc

Geopython rules!!!

Thanks
Lew
Reply all
Reply to author
Forward
0 new messages