Hello, I am trying to use the ArcGIS API for Python to read the Description from the Overview page on for an item.
For reference, the item is a .csv. We use the description to store the SQL that creates the .csv and I want to be able to read the SQL text from the description in order to execute it on my database and then updated and re-publish the .csv
Using the following code, I can read the description, but it returns it in HTML format:
from arcgis.gis import GIS
from pprint import pprint
gis = GIS("https://myURL.com", agol_username, agol_password)
item_data = gis.content.get(my_item_id)
data = item_data.description
pprint(data)
I am wondering if there is a way to print just the text from the Description? Something like (although 'text' is not a method in the API)
data = item_data.description.text
Any suggestions. I can't seem to find anything in the docs.
Maybe something like this?
import re
from arcgis.gis import GIS
from pprint import pprint
gis = GIS("https://myURL.com", agol_username, agol_password)
item_data = gis.content.get(my_item_id)
data = item_data.description
pattern = re.compile("<.*?>")
clean_text = re.sub(pattern, "", data)
pprint(clean_text)
Sounds like you just need to strip out the html tags, I think. I'm not sure what your description looks like, but you may also have to account for some other things like newline. Using print might yield better results in this case.