<?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: If-then statement/true-false condition in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/if-then-statement-true-false-condition/m-p/505666#M1684</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: MCline19&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Specifically: Lines 47-50.&amp;nbsp; I am aware the host email variable is missing (waiting to receive that info from another individual).&amp;nbsp; I've been omitting that portion of the code when I run it - just trying to get the "Sending email" print statement to print for a confirmation that it is going through the correct channels.&amp;nbsp; But whether the feature compare condition is true or false, the if-then statement always runs it as though true and never executes my "else" print statement.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Jan 2013 15:36:43 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2013-01-09T15:36:43Z</dc:date>
    <item>
      <title>If-then statement/true-false condition</title>
      <link>https://community.esri.com/t5/transportation-questions/if-then-statement-true-false-condition/m-p/505663#M1681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: MCline19&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm having a problem with my second If-then statement.&amp;nbsp; It seems like it should be a simple fix, but I'm new to coding so I'm struggling to figure out why I have my first and second If-then statements set up the same and the first works, but the second doesn't.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For the second If-then statement, whether the feature compare condition is true or false, the if-then statement always runs it as though true and therefore never executes my "else".&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any advise is greatly apprecaited.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy import os import datetime from datetime import date, timedelta from arcpy import env env.workspace = r'G:\GISAdmin\NEW_ROADS_NOTIFICATION\Road_Exports' import smtplib import string&amp;nbsp; # Scheduler. Determines the day of the week.&amp;nbsp; Program only checks for new road additions on weekdays. print ("Finding current date and time...") now = datetime.datetime.now() dayofweek = datetime.datetime.now().weekday() print now if dayofweek == 0:&amp;nbsp; print ("Monday") elif dayofweek == 1:&amp;nbsp; print ("Tuesday") elif dayofweek == 2:&amp;nbsp; print ("Wednesday") elif dayofweek == 3:&amp;nbsp; print ("Thursday") elif dayofweek == 4:&amp;nbsp; print ("Friday") else:&amp;nbsp; print ("End: Not programmed to run on weekends.")&amp;nbsp; #Export public_works.PW.Streets to shapefile and name according to the date todaysdate = str(datetime.date.today()) todaysdate = todaysdate.replace('-', '_') print todaysdate if dayofweek in [0, 1, 2, 3, 4]:&amp;nbsp; arcpy.CopyFeatures_management(r'G:\Department Projects\Public Works\Public Works.sde\public_works.PW.Streets', r'G:\GISAdmin\NEW_ROADS_NOTIFICATION\Road_Exports\roads' + todaysdate + '.shp') else:&amp;nbsp; print ("End: Not programmed to run on weekends (2).")&amp;nbsp; #Feature compare.&amp;nbsp; Compare yesterdays file with Todays new file. yesterday = str(date.today() - timedelta(1)) yesterday = yesterday.replace('-', '_') #yesterday = "2013_01_07" print yesterday todaysfile = r'G:\GISAdmin\NEW_ROADS_NOTIFICATION\Road_Exports\roads' + todaysdate + '.shp' yesterfile = r'G:\GISAdmin\NEW_ROADS_NOTIFICATION\Road_Exports\roads' + yesterday + '.shp' print todaysfile print yesterfile&amp;nbsp; if arcpy.FeatureCompare_management(yesterfile, todaysfile, "FID"):&amp;nbsp; print ("No changes detected in " + todaysfile + ". No further processing necessary.") else:&amp;nbsp; print ("Sending email...")&amp;nbsp; SUBJECT = "Steets layer changed detected"&amp;nbsp; TO = "python@mydomain.com"&amp;nbsp; FROM = "python@mydomain.com"&amp;nbsp; text = "Breaking News!&amp;nbsp; A change has been detected in the Public Works street spatial database."&amp;nbsp; BODY = string.join(( &amp;nbsp; "From: %s" % FROM, &amp;nbsp; "To: %s" % TO, &amp;nbsp; "Subject: %s" % SUBJECT , &amp;nbsp; "", &amp;nbsp; text &amp;nbsp; ), "\r\n")&amp;nbsp; server = smtplib.SMTP(HOST)&amp;nbsp; server.sendmail(FROM, [TO], BODY)&amp;nbsp; server.quit()&amp;nbsp; print ("Email sent!")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2013 15:03:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/if-then-statement-true-false-condition/m-p/505663#M1681</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-01-09T15:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: If-then statement/true-false condition</title>
      <link>https://community.esri.com/t5/transportation-questions/if-then-statement-true-false-condition/m-p/505664#M1682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Which line are you having a problem with? Looking at your email else statement you have nothing assigned to your HOST variable so it won't work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2013 15:20:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/if-then-statement-true-false-condition/m-p/505664#M1682</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-01-09T15:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: If-then statement/true-false condition</title>
      <link>https://community.esri.com/t5/transportation-questions/if-then-statement-true-false-condition/m-p/505665#M1683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: curtvprice&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;PRE class="plain" name="code"&gt;if arcpy.FeatureCompare_management(yesterfile, todaysfile, "FID"):&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The above code (the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;third&lt;/SPAN&gt;&lt;SPAN&gt; if, BTW) will not work because the tool returns a &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/002z/002z0000000n000000.htm#ESRI_SECTION1_4BF92292703248F09479E3D45CB23904" rel="nofollow" target="_blank"&gt;result object,&lt;/A&gt;&lt;SPAN&gt; not a boolean. You need to unpack the result object to get the boolean out. From the help for the tool:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;The comparison tools &lt;STRONG&gt;result object&lt;/STRONG&gt; will be 'true' when no differences are found and 'false' when differences are detected.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2013 15:31:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/if-then-statement-true-false-condition/m-p/505665#M1683</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-01-09T15:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: If-then statement/true-false condition</title>
      <link>https://community.esri.com/t5/transportation-questions/if-then-statement-true-false-condition/m-p/505666#M1684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: MCline19&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Specifically: Lines 47-50.&amp;nbsp; I am aware the host email variable is missing (waiting to receive that info from another individual).&amp;nbsp; I've been omitting that portion of the code when I run it - just trying to get the "Sending email" print statement to print for a confirmation that it is going through the correct channels.&amp;nbsp; But whether the feature compare condition is true or false, the if-then statement always runs it as though true and never executes my "else" print statement.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2013 15:36:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/if-then-statement-true-false-condition/m-p/505666#M1684</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-01-09T15:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: If-then statement/true-false condition</title>
      <link>https://community.esri.com/t5/transportation-questions/if-then-statement-true-false-condition/m-p/505667#M1685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: MCline19&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That makes sense.&amp;nbsp; Thanks Curtis.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2013 15:38:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/if-then-statement-true-false-condition/m-p/505667#M1685</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-01-09T15:38:40Z</dc:date>
    </item>
  </channel>
</rss>

