<?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: Select by Attribute and Calculate from old AML in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/select-by-attribute-and-calculate-from-old-aml/m-p/429696#M33781</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Michael,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd imagine it would be when they switch desktop to 64-bit native, since as far as I know .mdb files cannot be accessed by 64-bit applications. Server already has dropped support for personal geodatabases because of this. The earliest I'd imagine this would happen would be the version after 10.2. Of course they may simply switch personal geodatabases to .accdb and retain support. It's anyones guess at this point though, I haven't heard anything official either way.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Jun 2013 20:15:43 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2013-06-19T20:15:43Z</dc:date>
    <item>
      <title>Select by Attribute and Calculate from old AML</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-and-calculate-from-old-aml/m-p/429692#M33777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am not a person who works with Python but I am trying to convert an old AML into Python. Right now I am going line by line in the command prompt to see what works and then save that to a file.&amp;nbsp; What i need to do is a simple select by attribute and calculate an item based on the selected set. Is there no straight forward way to do this?&amp;nbsp; I am in v 10.1 if that matters. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the original AML querry and calc was simple&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Select: &lt;P&gt; &amp;gt;= 30 AND (( [PF] is null ) AND&amp;nbsp; ( [MC] = 300 ))&lt;/P&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Calc: [PF] = 'Char'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To attempt to duplicate this in Python, I've done the following: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FPlan = "C:\\path\&amp;lt;mine&amp;gt;.mdb\\FP&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management = (FPlan, "F")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management ("F", "NEW_SELECTION", " &lt;P&gt; &amp;gt;= 30 AND ( [PF] = '' AND [MC] = 300) ")&lt;/P&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- I think this is selecting items, all it returns is &amp;lt;Result 'F'&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CalculateField_management(calcF, "P", "Char")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-and this statement errors out. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please, can anyone tell me how to determin if A) features are selected and B) how to correctly calc the selected set into the &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;item &lt;P&gt;.&lt;/P&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very much!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Amy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 17:54:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-and-calculate-from-old-aml/m-p/429692#M33777</guid>
      <dc:creator>AmyDoyle</dc:creator>
      <dc:date>2013-06-19T17:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: Select by Attribute and Calculate from old AML</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-and-calculate-from-old-aml/m-p/429693#M33778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can bypass the Select Layer By Attributes execution because Make Feature Layer has an parameter in which to enter your query statement...pass that layer to your Calculate Field execution.&amp;nbsp; Also, if you know how many features the query results in, it's a good idea to test that with GetCount_management.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps...also see the webhelp for setting up queries, there are both Python and VBScript (and I think JScript) sytax guidance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enjoy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PS: Although there are various techniques for specifying a query, see this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Specifying a query in Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Desktop » Geoprocessing » Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000001r000000"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000001r000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 18:00:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-and-calculate-from-old-aml/m-p/429693#M33778</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-06-19T18:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Select by Attribute and Calculate from old AML</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-and-calculate-from-old-aml/m-p/429694#M33779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;First I would try to avoid personal geodatabases as support for them is waning.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Second you can use a cursor with a where clause and do it all in 4 lines.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;cursor = arcpy.da.UpdateCursor(FPlan, ["PF"], '''"P" &amp;gt;= 30 AND (("PF" is null ) AND ("MC" = 300 ))''')
for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; row[0] = 'Char'
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.updateRow(row)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:19:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-and-calculate-from-old-aml/m-p/429694#M33779</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T19:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Select by Attribute and Calculate from old AML</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-and-calculate-from-old-aml/m-p/429695#M33780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Matthew:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you have any idea when personal geodatabases will no longer be available?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 19:22:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-and-calculate-from-old-aml/m-p/429695#M33780</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2013-06-19T19:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: Select by Attribute and Calculate from old AML</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-and-calculate-from-old-aml/m-p/429696#M33781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Michael,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd imagine it would be when they switch desktop to 64-bit native, since as far as I know .mdb files cannot be accessed by 64-bit applications. Server already has dropped support for personal geodatabases because of this. The earliest I'd imagine this would happen would be the version after 10.2. Of course they may simply switch personal geodatabases to .accdb and retain support. It's anyones guess at this point though, I haven't heard anything official either way.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 20:15:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-and-calculate-from-old-aml/m-p/429696#M33781</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-06-19T20:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: Select by Attribute and Calculate from old AML</title>
      <link>https://community.esri.com/t5/python-questions/select-by-attribute-and-calculate-from-old-aml/m-p/429697#M33782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;the original AML querry and calc was simple&lt;BR /&gt;Select: &lt;P&gt; &amp;gt;= 30 AND (( [PF] is null ) AND&amp;nbsp; ( [MC] = 300 ))&lt;BR /&gt;Calc: [PF] = 'Char'&lt;BR /&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Amy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;knew&lt;/SPAN&gt;&lt;SPAN&gt; AML. AML was a &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;friend&lt;/SPAN&gt;&lt;SPAN&gt; of mine. This is not AML. Avenue, VBA maybe?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Please, can anyone tell me how to determin if A) features are selected and B) how to correctly calc the selected set into the &lt;BR /&gt;item &lt;P&gt;.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's a direct answer to your question&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
arcpy.env.workspace = "myfile.mdb" 
pvar = arcpy.&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v0000004n000000" rel="nofollow noopener noreferrer" target="_blank"&gt;AddFieldDelimeters&lt;/A&gt;("P") # 
 for mdb, "P" otherwise
pfvar = arcpy.AddFieldDelimeters("PF")
mcvar = arcpy.AddFieldDelimeters("MC")
where = '{0} &amp;gt; 30 AND (({1} IS NULL) AND ({2} = 300))'.format(pvar,pfvar,mcvar)
lyr = arcpy.MakeFeatureLayer_management(features, "lyr", where)
result = arcpy.GetCount_management(lyr)
nselect = int(result.getOutput(0))
print str(nselect), " selected"
arcpy.CalculateField_management(lyr, "P", "'Char'", "PYTHON_9.3")
arcpy.Delete_management(lyr) # clean up
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:19:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-by-attribute-and-calculate-from-old-aml/m-p/429697#M33782</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T19:19:44Z</dc:date>
    </item>
  </channel>
</rss>

