UnicodeDecodeError: 'utf8' codec- arcpy

المشرف العام

Administrator
طاقم الإدارة
I work with arcmap 10.3 and python 2.7.8. I have more than 500 shapefiles that located in many folders and subFolders. All Sub Folders are located in one large directory. I try with arcpy to detect all shapefiles that have in their attribute table ,in field name "YEUD", the value 20. I search all shape files that begin with letters "mig". Finally i tried to print all the shapefiles that had been found with value 20 in it.When i run this code:

import arcpy,os,fnmatch,unicodedata,codecsrootPath = r"C:\Project\layers" pattern = 'mig*.shp' for root, dirs, files in os.walk(rootPath): for filename in fnmatch.filter(files, pattern): shp = os.path.join(root, filename) if arcpy.ListFields(shp, "YEUD"): print("{} has YEUD field".format(shp)) with arcpy.da.SearchCursor(shp, ["YEUD"]) as rows: for row in rows: if row[0] == 52: print("{} has a record with YEUD = wanted row".format(shp)) breaki get an error when the python meet files and folders with right to left font:

UnicodeDecodeError: 'utf8' codec can't decode byte 0xe7 in position 23: invalid continuation byteFor completeness, i asked this question in https://geonet.esri.com/message/519769#519769 and saw answers in stackOverflow but didn't understand how to unicode the script. Thanks for any help.



أكثر...
 
أعلى