Hi,
I am working with ArcMap, if needed I can install PRO on the machine.
I have a folder with multiple SHP.
I have to modify part of the string in multiple fields and for all my SHPs. THE SAME replacement across all my fields and SHPs.
Tried already code block in single SHP, Model builder and python....all failed.
according to the example below: how do I change ALL "https" into "http" for both SHPs?
thanks!
If you have tried code and it failed, it helps to share what you tried and the error message with traceback. That way, people can make specific comments on what you tried.
In terms of the actual 'https' to 'http' replacement, that can be easily achieved using a Python string replacement:
>>> url = "https://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000011000000"
>>> new_url = url.replace('https:', 'http:')
>>> new_url
'http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000011000000'
>>>
Next, embed that code in an update cursor:
from arcpy import da
table = # path to shape file
fields = ["Link1", "Link2", "Link3"]
with da.UpdateCursor(table, fields) as cursor:
for row in cursor:
row = [s.replace('https:', 'http:') for s in row]
cursor.updateRow(row)