<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python script to remove spaces in notebook in ArcGIS Notebooks Questions</title>
    <link>https://community.esri.com/t5/arcgis-notebooks-questions/python-script-to-remove-spaces-in-notebook/m-p/1011208#M226</link>
    <description>&lt;P&gt;I have to automate it in AGOL so as far as I know the only way would be through using notebook? This is the first time I have used python at all. Yea I think I am in over my head but do not have much of a choice due to some things not being supported in Survey 123. The code you provided is starting to make sense as far as how things are being defined and later called. I am thinking that arcpy might already be in the AGOL notebook so perhaps it doesn't need to be imported or called at all. Thanks for your help. I will just keep trying stuff until something serious breaks.&lt;/P&gt;</description>
    <pubDate>Sat, 19 Dec 2020 00:54:35 GMT</pubDate>
    <dc:creator>JonathanWhite1</dc:creator>
    <dc:date>2020-12-19T00:54:35Z</dc:date>
    <item>
      <title>Python script to remove spaces in notebook</title>
      <link>https://community.esri.com/t5/arcgis-notebooks-questions/python-script-to-remove-spaces-in-notebook/m-p/1011097#M222</link>
      <description>&lt;P&gt;I'm having real trouble with getting a script to run in notebook to simply remove spaces from a field.&lt;/P&gt;&lt;P&gt;item=gis.content.get('528e3960da004561999c50dcaa52a781')&lt;BR /&gt;l=item.layers[0]&lt;/P&gt;&lt;P&gt;print(l.calculate(where="OBJECTID &amp;gt; 0",&lt;BR /&gt;calc_expression={"field": "test2", "sqlExpression": "Replace(test2," ","")"}))&lt;/P&gt;&lt;P&gt;This fails and upon further investigation the REPLACE SQL function is not supported. So I need a python script to run and remove spaces in a hosted feature layer's field. The reason why is a long story but this has to be running at least every 30 minutes 24/7, for the extent of COVID..&amp;nbsp; The field I am trying to remove spaces from is called test2. If I can get something to work then ill use the code on the actual feature layer.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;I pretty much have no idea what I am doing with notebook.&amp;nbsp;&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 19:52:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-notebooks-questions/python-script-to-remove-spaces-in-notebook/m-p/1011097#M222</guid>
      <dc:creator>JonathanWhite1</dc:creator>
      <dc:date>2020-12-18T19:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to remove spaces in notebook</title>
      <link>https://community.esri.com/t5/arcgis-notebooks-questions/python-script-to-remove-spaces-in-notebook/m-p/1011144#M223</link>
      <description>&lt;P&gt;The only thing I could find was this:&lt;/P&gt;&lt;P&gt;&lt;A href="https://gis.stackexchange.com/questions/363932/how-can-i-use-updatecursor-in-agol-layers" target="_blank" rel="noopener"&gt;python - How can I use UpdateCursor in AGOL layers? - Geographic Information Systems Stack Exchange&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#example from link
g = GIS("https://www.arcgis.com", USER, PASS)

token = g._con.token

fs = g.content.search(query="title:My Service", max_items=10)
url = fs[0].layers[0].url
print(url)

featureset = arcpy.FeatureSet()
authenticatedURL = url + "?token={}".format(token)
featureset.load(authenticatedURL)

with arcpy.da.UpdateCursor(authenticatedURL , "*") as cursor:
    for row in cursor:
        row[0] = "hello"
        cursor.updateRow(row)


#what you might try, definitely won't work
#first time, but you may be able to adjust it

g = GIS("https://www.arcgis.com", USER, PASS)

token = g._con.token

item = gis.content.get('528e3960da004561999c50dcaa52a781')
l=item.layers[0]
url = l.url
print(url)

featureset = arcpy.FeatureSet()
authenticatedURL = url + "?token={}".format(token)
featureset.load(authenticatedURL)

#run a cursor on field 'test2'
with arcpy.da.UpdateCursor(authenticatedURL , "test2") as cursor:
    for row in cursor:
        row[0] = row[0].replace(" ","")
        cursor.updateRow(row)
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 20:58:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-notebooks-questions/python-script-to-remove-spaces-in-notebook/m-p/1011144#M223</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-12-18T20:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to remove spaces in notebook</title>
      <link>https://community.esri.com/t5/arcgis-notebooks-questions/python-script-to-remove-spaces-in-notebook/m-p/1011199#M224</link>
      <description>&lt;P&gt;Yea its saying arcpy is not defined.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Dec 2020 00:14:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-notebooks-questions/python-script-to-remove-spaces-in-notebook/m-p/1011199#M224</guid>
      <dc:creator>JonathanWhite1</dc:creator>
      <dc:date>2020-12-19T00:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to remove spaces in notebook</title>
      <link>https://community.esri.com/t5/arcgis-notebooks-questions/python-script-to-remove-spaces-in-notebook/m-p/1011202#M225</link>
      <description>&lt;P&gt;Do you have to do it in the notebook? Can you import arcpy in the notebook (I'm not really conversant in the notebook interface)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Outside a notebook I gues you would need&lt;/P&gt;&lt;P&gt;&lt;EM&gt;from arcgis&lt;/EM&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;EM&gt;gis&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;import GIS&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;'yea' isn't a great reply to someone who spent time to assist you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Dec 2020 00:33:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-notebooks-questions/python-script-to-remove-spaces-in-notebook/m-p/1011202#M225</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-12-19T00:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to remove spaces in notebook</title>
      <link>https://community.esri.com/t5/arcgis-notebooks-questions/python-script-to-remove-spaces-in-notebook/m-p/1011208#M226</link>
      <description>&lt;P&gt;I have to automate it in AGOL so as far as I know the only way would be through using notebook? This is the first time I have used python at all. Yea I think I am in over my head but do not have much of a choice due to some things not being supported in Survey 123. The code you provided is starting to make sense as far as how things are being defined and later called. I am thinking that arcpy might already be in the AGOL notebook so perhaps it doesn't need to be imported or called at all. Thanks for your help. I will just keep trying stuff until something serious breaks.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Dec 2020 00:54:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-notebooks-questions/python-script-to-remove-spaces-in-notebook/m-p/1011208#M226</guid>
      <dc:creator>JonathanWhite1</dc:creator>
      <dc:date>2020-12-19T00:54:35Z</dc:date>
    </item>
  </channel>
</rss>

