Hello,
I'm trying to create an expression that will return the list of layers that are in a webmap.
So far I have this
from arcgis.gis import GIS
from arcgis.mapping import WebMap
gis = GIS("home")
wmItemId = "" #put the id of the webmap in here
wmItem = gis.content.get(wmItemId)
wm = WebMap(wmItem)for lyr in wm.layers:
print(lyr.title)
But get this error after running (when I have the webmap ID included)
Input In [1] print(lyr.title) ^ SyntaxError: invalid non-printable character U+200D
What could be causing this error? Also, is it possible to have the expression automatically generate a CSV file with the list instead of printing one? Any help is appreciated.
Thanks.
Solved! Go to Solution.
When I paste your code, I see this:
Somehow, you've got a 'non-printable character' in there, the zero-width joiner: "" U+200D: Zero Width Joiner (Unicode Character) (unicodeplus.com)
Try just re-typing that line manually. I'm assuming this was pasted from some other code snippet somewhere? Not sure how else that character would've gotten in. When I run your same code, but typed instead of pasted, it works fine.
When I paste your code, I see this:
Somehow, you've got a 'non-printable character' in there, the zero-width joiner: "" U+200D: Zero Width Joiner (Unicode Character) (unicodeplus.com)
Try just re-typing that line manually. I'm assuming this was pasted from some other code snippet somewhere? Not sure how else that character would've gotten in. When I run your same code, but typed instead of pasted, it works fine.
That worked! Super weird.
Thanks for the help.