<?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: Convert arcmap to ArcGIS PRO - scripts in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119646#M63039</link>
    <description>&lt;P&gt;My problem is basically converting this snippet that is in VB and I can't find similar in PRO. This is a date field, and it says I can't slice a date field.&lt;/P&gt;&lt;P&gt;- Right( [PLANTIO],4 )&lt;/P&gt;</description>
    <pubDate>Tue, 23 Nov 2021 19:05:11 GMT</pubDate>
    <dc:creator>SoratoSouza_e_Silva</dc:creator>
    <dc:date>2021-11-23T19:05:11Z</dc:date>
    <item>
      <title>Convert arcmap to ArcGIS PRO - scripts</title>
      <link>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119636#M63035</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Is there any practical way to convert scripts from arcmap to arcgis pro?&lt;/P&gt;&lt;P&gt;I need to convert several scripts, and for example this snippet I'm having a lot of problems.&lt;/P&gt;&lt;P&gt;arcpy.CalculateField_management("temp_informe_Layer", "EST_SUBREP", "" + anoAtual + " - Right( [PLANTIO],4 )", "VB", "")&lt;/P&gt;&lt;P&gt;would anyone know help me with the correct syntax for Arcgis PRO?&lt;/P&gt;&lt;P&gt;Thank´s&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 18:49:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119636#M63035</guid>
      <dc:creator>SoratoSouza_e_Silva</dc:creator>
      <dc:date>2021-11-23T18:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Convert arcmap to ArcGIS PRO - scripts</title>
      <link>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119639#M63036</link>
      <description>&lt;P&gt;How about create a simple model in Pro using that specific query and see what the python export script looks like?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 18:55:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119639#M63036</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2021-11-23T18:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: Convert arcmap to ArcGIS PRO - scripts</title>
      <link>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119640#M63037</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/tables/fundamentals-of-field-calculations.htm" target="_blank"&gt;Fundamentals of field calculations—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field.htm" target="_blank"&gt;Calculate Field (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field-examples.htm" target="_blank"&gt;Calculate Field Python examples—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;to get you started&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 18:56:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119640#M63037</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-11-23T18:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert arcmap to ArcGIS PRO - scripts</title>
      <link>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119643#M63038</link>
      <description>&lt;P&gt;My problem is basically converting this snippet that is in VB and I can't find similar in PRO. This is a date field, and it says I can't slice a date field.&lt;/P&gt;&lt;P&gt;- Right( [PLANTIO],4 )&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 19:03:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119643#M63038</guid>
      <dc:creator>SoratoSouza_e_Silva</dc:creator>
      <dc:date>2021-11-23T19:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Convert arcmap to ArcGIS PRO - scripts</title>
      <link>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119646#M63039</link>
      <description>&lt;P&gt;My problem is basically converting this snippet that is in VB and I can't find similar in PRO. This is a date field, and it says I can't slice a date field.&lt;/P&gt;&lt;P&gt;- Right( [PLANTIO],4 )&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 19:05:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119646#M63039</guid>
      <dc:creator>SoratoSouza_e_Silva</dc:creator>
      <dc:date>2021-11-23T19:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Convert arcmap to ArcGIS PRO - scripts</title>
      <link>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119647#M63040</link>
      <description>&lt;P&gt;Hello SoratoSouza_e_Silva,&lt;/P&gt;&lt;P&gt;ArcMap uses Python 2 while ArcGIS Pro use Python 3. Many scripts will still be functional, but some will not. Esri and Python.org has some documentation that discusses the change. See below:&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/python-migration-for-arcgis-pro.htm" target="_self"&gt;Python migration from 10.x to ArcGIS Pro&lt;/A&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Some general information about the change plus extra resources.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/analyzetoolsforpro.htm" target="_self"&gt;Analyze Tools for Pro (Data Management)&lt;/A&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;A data management geoprocessing tool that can identify potential scripts that will have a problem running successfully.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;A href="https://docs.python.org/3/library/2to3.html" target="_self"&gt;2to3 - Automated Python 2 to 3 code translation&lt;/A&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;A command line utility to convert Python 2 code to Python 3 code.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I'd make sure to read up on any other these before making changes (especially the 2to3 command line utility). For safety, I'd recommend making a copy of the script(s) and making changes to the copy rather than the original.&lt;/P&gt;&lt;P&gt;I hope this is helpful and have fun!&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 19:05:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119647#M63040</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-11-23T19:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Convert arcmap to ArcGIS PRO - scripts</title>
      <link>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119652#M63041</link>
      <description>&lt;P&gt;VB is not supported in ArcGIS Pro.&lt;/P&gt;&lt;P&gt;Try PYTHON3, ARCADE or SQL.&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;!PLANTIO![-4:]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Also Replace "VB" with "PYTHON3"&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 19:27:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119652#M63041</guid>
      <dc:creator>JayantaPoddar</dc:creator>
      <dc:date>2021-11-23T19:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Convert arcmap to ArcGIS PRO - scripts</title>
      <link>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119697#M63043</link>
      <description>&lt;P&gt;If it is a date field, you can use python expressions to work with dates, or more simply convert it to a string representation prior to slicing&lt;/P&gt;&lt;P&gt;assume datetime.datetime.now represents !PLANTIO!&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import datetime

datetime.datetime.now()
Out[2]: datetime.datetime(2021, 11, 23, 16, 42, 51, 182197)

str(datetime.datetime.now())  # str(!PLANTIO!)  *****
Out[3]: '2021-11-23 16:43:08.012047'

str(datetime.datetime.now())[:4]  # str(!PLANTIO!)[:4]  *****
Out[4]: '2021'  # the year&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 23 Nov 2021 21:45:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119697#M63043</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-11-23T21:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Convert arcmap to ArcGIS PRO - scripts</title>
      <link>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119709#M63044</link>
      <description>&lt;P&gt;Thank you so much, you are fantastic...&lt;/P&gt;&lt;P&gt;But I think I wasn't very clear, I'll need to do a numerical count, and I can't subtract string:&lt;/P&gt;&lt;PRE&gt;arcpy.CalculateField_management(&lt;SPAN&gt;"temp_informe_Layer"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"EST_SUBREP"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"" &lt;/SPAN&gt;+ anoAtual + &lt;SPAN&gt;" -  Right( [PLANTIO],4 )"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"VB"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;My data format is 23/11/2021&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 22:24:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119709#M63044</guid>
      <dc:creator>SoratoSouza_e_Silva</dc:creator>
      <dc:date>2021-11-23T22:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: Convert arcmap to ArcGIS PRO - scripts</title>
      <link>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119764#M63046</link>
      <description>&lt;P&gt;still not clear since I don't know what the values are or what they represent, but if you have a number and a string and you want to subtract them, then&lt;/P&gt;&lt;P&gt;anoAtual = 100&lt;/P&gt;&lt;P&gt;fld = "2000"&lt;/P&gt;&lt;P&gt;anoAtual - int(fld)&lt;BR /&gt;-1900&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 01:26:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119764#M63046</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-11-24T01:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert arcmap to ArcGIS PRO - scripts</title>
      <link>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119788#M63048</link>
      <description>&lt;P&gt;The issue you may be running into is that VB doesn't care about data type, if you throw a string function at it, it will use a string rep of the value. For example, you can add "1" and "1" and get 2.&amp;nbsp; In Python you need to convert data types yourself, so, assuming your PLANTIO is a date field, you may be able to get what you want like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;expr = 'float(' &amp;amp; str(anuAtual) &amp;amp; ') - float(time.strftime(!PLANTIO!,"%Y"))'
# at runtime, expr will be something like: 
# float(1999) - float(time.strftime(!PLANTIO!,"%Y"))
arcpy.CalculateField_management("temp_informe_Layer", "EST_SUBREP", 
    expr, "PYTHON")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;More on handling dates in Calculate Field &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field-examples.htm#ESRI_SECTION1_AFC203DD316B4543A729B413C3322F3C" target="_self"&gt;in the help&lt;/A&gt;!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 05:00:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119788#M63048</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-11-24T05:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Convert arcmap to ArcGIS PRO - scripts</title>
      <link>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119841#M63049</link>
      <description>&lt;P&gt;Thank´s,&lt;/P&gt;&lt;P&gt;Thank you very much for your suggestion. It's a great option too!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 11:06:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1119841#M63049</guid>
      <dc:creator>SoratoSouza_e_Silva</dc:creator>
      <dc:date>2021-11-24T11:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Convert arcmap to ArcGIS PRO - scripts</title>
      <link>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1200215#M65234</link>
      <description>&lt;P&gt;For some reason this popped up in my email so I thought I'd add that using string formatting is easier to understand and debug. This is especially true if your expression is complex.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;expr = 'float({}) - float(time.strftime(!PLANTIO!,"%Y"))'.format(anuAtual)
# at runtime, expr will be something like: 
# float(1999) - float(time.strftime(!PLANTIO!,"%Y"))
arcpy.CalculateField_management("temp_informe_Layer", "EST_SUBREP", 
    expr, "PYTHON")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Aug 2022 17:54:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-arcmap-to-arcgis-pro-scripts/m-p/1200215#M65234</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2022-08-07T17:54:48Z</dc:date>
    </item>
  </channel>
</rss>

