This is a portion of an inherited code, we have recently upgraded to a more current Enterprise.
The code worked on the older Enterprise version, he rest of the code has been updated and seems to be running fine when run as individual cells.
The Error message:
In [12]:
Line 13: with arcpy.da.SearchCursor(fc, fields, query) as row:
TypeError: 'field_names' must be string or non empty sequence of strings
---------------------------------------------------------------------------
The code:
#Extract Tax Parcels from Parcel Editing (Feature Service on Portal)
source = r"UPDATEDENTERPRISE/HOSTED//FEATURELAYER/FeatureServer/0"
fc = r"UPDATEDENTERPRISE/HOSTED//FEATURELAYER/FeatureServer/0"
CSVFile = r"S:\LOCALSERVERPATH\GISDATA.csv"
query = """("Name" NOT LIKE BLAHBLAHBLAH)"""
fields = [f.name for f in arcpy.ListFields(fc) if f.name in ('Name')]
with open(CSVFile, 'w') as f:
f.write(','.join(fields)+'\n') #csv headers
with arcpy.da.SearchCursor(fc, fields, query) as row:
for row in rows:
f.write(','.join([str(r) for r in row])+'\n')
print("CSV File Created for GIS")
I've been looking through StackExchange, StackOverflow, Esri Community, etc. for a couple of days now and have tried variations on suggestions but continue to get the same error.
Any suggestions will be very welcome. I am new to this.
Thank you