I am trying to write a Python script that uses a xls file with different spreadsheets as input to build features and domains in a geodatabase.
This is the data in Sheet1:
and this the data in Sheet2
and I would like to use this as input for making features in a geodatabase. Below my script is displayed, but it returns the following error:
string indices must be integers
#---Import modules---# import pandas as pd import arcpy import xlrd #---Set paths---# SheetFeatureclass = pd.read_excel(r"C:\xlmtofeature\sheets.xls", sheet_name='Sheet1') SheetDomain = pd.read_excel(r"C:\xlmtofeature\sheets.xls", sheet_name='Sheet2') projection = r'C:\xlmtofeature\RD New.prj' out_path = r'C:\xlmtofeature\test.gdb' #---Colums in Sheet1---# FEATURENAME = SheetFeatureclass['FEATURENAME'] GEO_TYPE = SheetFeatureclass['GEO_TYPE'] #---Colums in Sheet2---# DOMEIN = SheetDomain ['DOMEIN'] FIELDTYPE = SheetDomain['FIELDTYPE'] DOMEINTYPE = SheetDomain ['DOMEINTYPE'] #---Create features ---# for row in SheetFeatureclass: try: arcpy.CreateFeatureclass_management(out_path, row[FEATURENAME], row[GEO_TYPE], "", "", "",projectie,"","","", "") print str(row[FEATURENAME]+ " Toegevoegd" ) except Exception as err: print(err.args) print "Done with adding features" #--- create Doamins ---# for row in SheetDomain: try: arcpy.CreateDomain_management(out_path, row[DOMEIN],"",row[FIELDTYPE],row[DOMEINTYPE],"","",) print str("Add "+ row[DOMEIN]) except Exception as err: print(err.args) print "Done with adding Domains"