<?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: Export feature layer data to text file in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/export-feature-layer-data-to-text-file/m-p/1434524#M70562</link>
    <description>&lt;P&gt;Found my issue.&amp;nbsp; It ended up being two things.&amp;nbsp; One I was calling out the row in two different areas and the count field was not processing correctly in my if statement was I turned the count into a string then it found the 0 values.&amp;nbsp; Here is my final working one.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;epath = Elog2
efile = open(epath, 'a')
etable = ElectricDup
fields = ['meternum','assetid']
today = str(date.today())
total = 0

count_row = str(arcpy.management.GetCount(
    in_rows = etable)
)
print (count_row)
if count_row == '0':
    print ("Empty List")
    efile.write("No Duplicate Meters on " + today + "\n")
else:
     with arcpy.da.SearchCursor(etable,fields) as cursor:
        for row in cursor:
            print ("Meter {} is duplicated on Asset ID {}".format(row[0],row[1]))
            efile.write("Recorded On " + today + " Meter {} is duplicated on Asset ID {}".format(row[0],row[1]) + "\n")
        
efile.close()&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 10 May 2024 21:21:53 GMT</pubDate>
    <dc:creator>LindseyStone</dc:creator>
    <dc:date>2024-05-10T21:21:53Z</dc:date>
    <item>
      <title>Export feature layer data to text file</title>
      <link>https://community.esri.com/t5/python-questions/export-feature-layer-data-to-text-file/m-p/1418945#M70521</link>
      <description>&lt;P&gt;Let me start with I'm very new to Python so please bare with me.&amp;nbsp; I have created a python script that deletes a feature layer "ElectricMeterDuplicates" out of a GDB, runs some other calculations commands and then exports the results back into the original GDB as a feature layer with the same name.&amp;nbsp; That part is all working correctly until I get to my text file I want to write results to.&amp;nbsp; I could have one of two situations. 1. the new feature layer contains 2 or more rows of data, here I want it to write to the text file the information form 2 fields for each row of data. OR the feature layer is empty and here I want it to write to the file I simple message of no data .&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have written the below script.&amp;nbsp; When I run it in Notebook within Pro it correctly writes to the text file if there is data, however, if there is no data it doesn't write anything.&amp;nbsp; When I run this as a standalone script through a bat file (which is my end goal, the entire thing errors out with&amp;nbsp;ERROR 000732: Input Rows: Dataset ElectricMeterDuplicates does not exist or is not supported and doesn't write anything to the text file no matter the situation.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;epath = r"Z:\General\Projects\Utility\Scripts\DuplicateMeters\Logs\ElectricDupMeters.txt"
efile = open(epath, 'a')
etable = r"Z:\General\Projects\Utility\Scripts\DuplicateMeters\DuplicateMeters.gdb\ElectricMeterDuplicates"
fields = ['meternum','assetid']
today = str(date.today())
total = 0

row = arcpy.management.GetCount(
    in_rows="ElectricMeterDuplicates"
)
print (row)
if row == 0:
    print ("Empty List")
    efile.write("No Duplicate Meters on " + today + "\n")
else:
     with arcpy.da.SearchCursor(etable,fields) as cursor:
        for row in cursor:
            print ("Meter {} is duplicated on Asset ID {}".format(row[0],row[1]))
            efile.write("Recorded On " + today + " Meter {} is duplicated on Asset ID {}".format(row[0],row[1]) + "\n")
        
efile.close()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2024 21:17:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-feature-layer-data-to-text-file/m-p/1418945#M70521</guid>
      <dc:creator>LindseyStone</dc:creator>
      <dc:date>2024-05-03T21:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Export feature layer data to text file</title>
      <link>https://community.esri.com/t5/python-questions/export-feature-layer-data-to-text-file/m-p/1418962#M70522</link>
      <description>&lt;LI-CODE lang="python"&gt;# in_rows="ElectricMeterDuplicates"
# try
in_rows = etable&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 03 May 2024 23:02:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-feature-layer-data-to-text-file/m-p/1418962#M70522</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2024-05-03T23:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: Export feature layer data to text file</title>
      <link>https://community.esri.com/t5/python-questions/export-feature-layer-data-to-text-file/m-p/1434524#M70562</link>
      <description>&lt;P&gt;Found my issue.&amp;nbsp; It ended up being two things.&amp;nbsp; One I was calling out the row in two different areas and the count field was not processing correctly in my if statement was I turned the count into a string then it found the 0 values.&amp;nbsp; Here is my final working one.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;epath = Elog2
efile = open(epath, 'a')
etable = ElectricDup
fields = ['meternum','assetid']
today = str(date.today())
total = 0

count_row = str(arcpy.management.GetCount(
    in_rows = etable)
)
print (count_row)
if count_row == '0':
    print ("Empty List")
    efile.write("No Duplicate Meters on " + today + "\n")
else:
     with arcpy.da.SearchCursor(etable,fields) as cursor:
        for row in cursor:
            print ("Meter {} is duplicated on Asset ID {}".format(row[0],row[1]))
            efile.write("Recorded On " + today + " Meter {} is duplicated on Asset ID {}".format(row[0],row[1]) + "\n")
        
efile.close()&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 10 May 2024 21:21:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-feature-layer-data-to-text-file/m-p/1434524#M70562</guid>
      <dc:creator>LindseyStone</dc:creator>
      <dc:date>2024-05-10T21:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Export feature layer data to text file</title>
      <link>https://community.esri.com/t5/python-questions/export-feature-layer-data-to-text-file/m-p/1434684#M70563</link>
      <description>&lt;P&gt;plus the etable thing in my thread &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2024 21:46:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-feature-layer-data-to-text-file/m-p/1434684#M70563</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2024-05-10T21:46:04Z</dc:date>
    </item>
  </channel>
</rss>

