I am trying to export a list of fields in feature class attribute table to excel spread sheet. I am getting most of the things right but i am getting error at one line of code.
I am getting attribute error 'NoneType' object has no attribute 'list' at :
param2.filter.list = ["xlsx"] Can anyone point out the cause of error and provide a solution.
Code:
def getParameterInfo(self): param1 = arcpy.Parameter( displayName = "Input Feature", name = "in_features", datatype = "DEFeatureClass", parameterType = "Required", direction= "Input") param1.filter.list = ["Polyline"] param2 = arcpy.Parameter( displayName='Output', name='excel', datatype='DEFile', parameterType='Optional', direction='Output') param2.filter.list = ["xlsx"] params = [param1, param2] return params def execute(self, parameters, messages): fc = parameters[0].valueAsText output = parameters[1].valueAsText fields = [f.name for f in arcpy.ListFields(fc)] l = [[row.getValue(field) for row in arcpy.SearchCursor(fc)] for field in fields ] book= xlwt.Workbook() sheet = book.add_sheet("Cable_info") for i in range(len(l)): sheet.write(0,i,fields) for i in range(2,len(l)): for j in range(1,len(l[0])): sheet.write(j,i, l[j]) book.save(output) return
أكثر...
I am getting attribute error 'NoneType' object has no attribute 'list' at :
param2.filter.list = ["xlsx"] Can anyone point out the cause of error and provide a solution.
Code:
def getParameterInfo(self): param1 = arcpy.Parameter( displayName = "Input Feature", name = "in_features", datatype = "DEFeatureClass", parameterType = "Required", direction= "Input") param1.filter.list = ["Polyline"] param2 = arcpy.Parameter( displayName='Output', name='excel', datatype='DEFile', parameterType='Optional', direction='Output') param2.filter.list = ["xlsx"] params = [param1, param2] return params def execute(self, parameters, messages): fc = parameters[0].valueAsText output = parameters[1].valueAsText fields = [f.name for f in arcpy.ListFields(fc)] l = [[row.getValue(field) for row in arcpy.SearchCursor(fc)] for field in fields ] book= xlwt.Workbook() sheet = book.add_sheet("Cable_info") for i in range(len(l)): sheet.write(0,i,fields) for i in range(2,len(l)): for j in range(1,len(l[0])): sheet.write(j,i, l[j]) book.save(output) return
أكثر...