HOW TO
In ArcGIS Pro, efficiently downloading data from every linked item listed in a table, where each item's URL is stored in a specific field, is possible. The SearchCursor function can be used to return rows of attribute values from a feature class or table. By iterating through the rows, the URLs can be extracted and listed from text fields containing only URL links, such as those starting with 'https' or 'www'. This approach provides streamlined data processing and facilitates further operations involving the extracted URLs. This article describes the workflow to list the URLs from the text fields using ArcPy.
Note: This workflow requires a full script to run in the ArcGIS Pro Python window. The indents must be retained as portrayed in the code block.
import arcpy table = r"<pathName>"
url_field = "URL"
url_list = []
with arcpy.da.SearchCursor(table, [url_field]) as cursor: for row in cursor: url = row[0] if url is not None: if url.startswith('https') or url.startswith('www'): url_list.append(url) else: pass
for url in url_list: print(url)
The code block below demonstrates the full working script.
import arcpy table = r" C:\Training\StartAnalytics\Data\FarmAnalysis.gdb\FarmMarket" url_field = "URL" url_list = [] with arcpy.da.SearchCursor(table, [url_field]) as cursor: for row in cursor: url = row[0] if url is not None: if url.startswith('https') or url.startswith('www'): url_list.append(url) else: pass for url in url_list: print(url)
The image below shows the URLs printed in the Python window.
Article ID: 000033279
Get help from ArcGIS experts
Download the Esri Support App