import arcpy
path=("C:/Users/fazeel/Desktop/ExampleCase/LeicesterCity_Leeds")
arcpy.env.workspace=path
fields=arcpy.ListFields("CandidateStations_Centroid")
for fld in fields:
print fld.name
I wonder to know the reason of this warring message, any suggestion please?
Many thanks
Solved! Go to Solution.
It seems the reason this is working is because you have a layer named "CandidateStations_Centroid" in your ArcMap session, so it is recognized in the ListFields.
Your path is referencing a folder and not a GeoDatabase, so you would need to make sure you are pointing to the actual feature class which I am assuming is a shapefile (CandidateStations_Centroid.shp).
try this
path = "C:/Users/fazeel/Desktop/ExampleCase/LeicesterCity_Leeds" # non-tuple version
Dear Dan
Thank you very much for your response. I tried it, but again it showed the same warning message!
Best regards,
Putting a single value in (parens) doesn't turn it into a tuple.
>>> path=("C:/Users/fazeel/Desktop/ExampleCase/LeicesterCity_Leeds")
>>> type(path)
<class 'str'>
You'd need to add a comma to get that:
>>> path=("C:/Users/fazeel/Desktop/ExampleCase/LeicesterCity_Leeds",)
>>> type(path)
<class 'tuple'>
always missing the comma...which is why I hate tuples
It seems the reason this is working is because you have a layer named "CandidateStations_Centroid" in your ArcMap session, so it is recognized in the ListFields.
Your path is referencing a folder and not a GeoDatabase, so you would need to make sure you are pointing to the actual feature class which I am assuming is a shapefile (CandidateStations_Centroid.shp).
Dear Dan
Thank you very much you are true,once I provided the extension "gdb" it worked.
Many thanks once again