<?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: How to Extract values from a field and write them to a text file using Python? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403996#M31816</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The .next() statement (in addition to the for loop) is unneccessary. I think a bit cleaner code would look like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
myOutputFile = open('C:\\temp\\myoutputfile.txt', 'w')
rows = ap.SearchCursor('C:\\temp\\myInputTable.shp')
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; myOutputFile.write(str(row.APN) + '\n')
del row, rows
myOutputFile.close()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, in v10.1 syntax using the .da cursors (~30x faster than the old search cursors):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
myOutputFile = open('C:\\temp\\myoutputfile.txt', 'w')
rows = arcpy.da.SearchCursor('C:\\temp\\myInputTable.shp',["APN"])
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; myOutputFile.write(str(row[0]) + '\n')
del row, rows
myOutputFile.close()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 18:24:46 GMT</pubDate>
    <dc:creator>ChrisSnyder</dc:creator>
    <dc:date>2021-12-11T18:24:46Z</dc:date>
    <item>
      <title>How to Extract values from a field and write them to a text file using Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403991#M31811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using ArcGIS 10.0 Python 2.6. I need to get the values from a single field (APN) out of a PARCEL feature class attribute table and write them to a text file.&amp;nbsp; The feature class contains about 20 different fields.&amp;nbsp; I only need to write the values from APN.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The only info I can find is outdated.&amp;nbsp; Can anyone help?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Christi Nelson&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 17:06:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403991#M31811</guid>
      <dc:creator>ChristiNelson1</dc:creator>
      <dc:date>2013-07-11T17:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract values from a field and write them to a text file using Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403992#M31812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is untested but I think it should do the trick.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy

def WriteFieldToText(table, field, text_file):

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Open search cursor to loop thru table
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.SearchCursor(table)
&amp;nbsp;&amp;nbsp;&amp;nbsp; f = open(text_file, 'w')
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write(str(row.getValue(field)) + '\n')
&amp;nbsp;&amp;nbsp;&amp;nbsp; del row, rows
&amp;nbsp;&amp;nbsp;&amp;nbsp; f.close()
&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'Created "%s"' %text_file
&amp;nbsp;&amp;nbsp;&amp;nbsp; 

if __name__ == '__main__':

&amp;nbsp;&amp;nbsp;&amp;nbsp; fc = r'C:\Path\To_your\featureClass'
&amp;nbsp;&amp;nbsp;&amp;nbsp; field = 'APN'
&amp;nbsp;&amp;nbsp;&amp;nbsp; output = r'C:\Path\To_your\textfile.txt'

&amp;nbsp;&amp;nbsp;&amp;nbsp; # run function
&amp;nbsp;&amp;nbsp;&amp;nbsp; WriteFieldToText(fc, field, output)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:24:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403992#M31812</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T18:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract values from a field and write them to a text file using Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403993#M31813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is very easily done. You can read a little about SearchCursors &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000039000000" rel="nofollow" target="_blank"&gt;here&lt;/A&gt;&lt;SPAN&gt;, and about writing to text files with Python &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://docs.python.org/2/tutorial/inputoutput.html" rel="nofollow" target="_blank"&gt;here&lt;/A&gt;&lt;SPAN&gt; (page down to section &lt;/SPAN&gt;&lt;STRONG&gt;7.2 Reading and Writing Files&lt;/STRONG&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The general pattern for this operation in AGD 10.0 is something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy as ap&amp;nbsp; # this is how you create a file in Python myOutputFile = open('C:\\temp\\myoutputfile.txt', 'w')&amp;nbsp; # create a row object to navigate your table rows = ap.SearchCursor('C:\\temp\\myInputTable.shp') row = rows.next()&amp;nbsp; # for each row in your table, retrieve the value in the 'APN' field, convert it # to a string, write it to your output file, then move to the next line in both # your input table and output file for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp; myOutputFile.write(str(row.APN) + '\n')&amp;nbsp; del row, rows myOutputFile.close()&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 17:56:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403993#M31813</guid>
      <dc:creator>PhilMorefield</dc:creator>
      <dc:date>2013-07-11T17:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract values from a field and write them to a text file using Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403994#M31814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;More than one way to do this, but I suppose the easiest (not necessarily the most efficient) is to use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Export Feature Attribute to ASCII (Spatial Statistics) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Resource Center » Professional Library » Geoprocessing » Geoprocessing tool reference » Spatial Statistics toolbox » Utilities toolset&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//005p0000003v000000"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//005p0000003v000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...also, the input can be a feature layer, meaning if you wanted you should be able to 'pare down' the output fields with the field info control.&amp;nbsp; This is available with the Make Feature Layer tool -- an example of how to use the field info control in a script is with the webhelp on Make Table View, so if you need that, it's here (and it should be used the same way with Make Feature Layer):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Make Table View (Data Management) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Resource Center » Professional Library » Geoprocessing » Geoprocessing tool reference » Data Management toolbox » Layers and Table Views toolset&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000006v000000"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000006v000000&lt;/A&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;BR /&gt;&lt;SPAN&gt;Edit:&amp;nbsp; It's even easier than that!&amp;nbsp; You don't need Make Feature Layer, you can specify what you wish in the 2nd param (Value_Field) of the Spatial Statistics tool.&amp;nbsp; One tool!&amp;nbsp; (if you don't mind the additional XY coords)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 17:57:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403994#M31814</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-07-11T17:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract values from a field and write them to a text file using Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403995#M31815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;This is very easily done. You can read a little about SearchCursors &lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000039000000" rel="nofollow noopener noreferrer" target="_blank"&gt;here&lt;/A&gt;, and about writing to text files with Python &lt;A href="http://docs.python.org/2/tutorial/inputoutput.html" rel="nofollow noopener noreferrer" target="_blank"&gt;here&lt;/A&gt; (page down to section &lt;STRONG&gt;7.2 Reading and Writing Files&lt;/STRONG&gt;.&lt;BR /&gt;&lt;BR /&gt;The general pattern for this operation in AGD 10.0 is something like this:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy as ap

# this is how you create a file in Python
myOutputFile = open('C:\\temp\\myoutputfile.txt', 'w')

# create a row object to navigate your table
rows = ap.SearchCursor('C:\\temp\\myInputTable.shp')
row = rows.next()

# for each row in your table, retrieve the value in the 'APN' field, convert it
# to a string, write it to your output file, then move to the next line in both
# your input table and output file
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; myOutputFile.write(str(row.APN) + '\n')

del row, rows
myOutputFile.close()&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you!&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This worked seamlessly.&amp;nbsp; Funny, I did read section 7.2 in the text you provided, but hit a road block trying to incorporate it with a search cursor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for all of your help, everyone!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Christi&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:24:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403995#M31815</guid>
      <dc:creator>ChristiNelson1</dc:creator>
      <dc:date>2021-12-11T18:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract values from a field and write them to a text file using Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403996#M31816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The .next() statement (in addition to the for loop) is unneccessary. I think a bit cleaner code would look like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
myOutputFile = open('C:\\temp\\myoutputfile.txt', 'w')
rows = ap.SearchCursor('C:\\temp\\myInputTable.shp')
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; myOutputFile.write(str(row.APN) + '\n')
del row, rows
myOutputFile.close()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, in v10.1 syntax using the .da cursors (~30x faster than the old search cursors):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
myOutputFile = open('C:\\temp\\myoutputfile.txt', 'w')
rows = arcpy.da.SearchCursor('C:\\temp\\myInputTable.shp',["APN"])
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; myOutputFile.write(str(row[0]) + '\n')
del row, rows
myOutputFile.close()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:24:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403996#M31816</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T18:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract values from a field and write them to a text file using Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403997#M31817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Christi, I had to give a point each to Caleb and Phil just because I thought it was neat to be able to compare the answers side by side --- both are good works!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you like Phil's work best, you probably ought to give him the 'green checkmark' - he deserves it.&lt;/SPAN&gt;&lt;BR /&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 - And a point to Chris for being so efficient.... I was wondering why noone mentioned the da (data access) module.&amp;nbsp; 30x faster is impressive!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 19:14:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403997#M31817</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-07-11T19:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract values from a field and write them to a text file using Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403998#M31818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Christi, I had to give a point each to Caleb and Phil just because I thought it was neat to be able to compare the answers side by side --- both are good works!&lt;BR /&gt;&lt;BR /&gt;If you like Phil's work best, you probably ought to give him the 'green checkmark' - he deserves it.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy,&lt;BR /&gt;Wayne&lt;BR /&gt;&lt;BR /&gt;PS - And a point to Chris for being so efficient.... I was wondering why noone mentioned the da (data access) module.&amp;nbsp; 30x faster is impressive!&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Done!&amp;nbsp; Both answers were terrific.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 19:25:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403998#M31818</guid>
      <dc:creator>ChristiNelson1</dc:creator>
      <dc:date>2013-07-11T19:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract values from a field and write them to a text file using Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403999#M31819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Just for fun, while talking about efficiency, may as well make to as few lines as possible &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
fc = r'G:\Data\Geodatabase\Cedar_County.gdb\CADASTRAL\PARCEL'
output = r'C:\Users\GIS\Desktop\textfile.txt'

with open(output, 'w') as f:
&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write('\n'.join(r.PID for r in arcpy.SearchCursor(fc)))
print 'Created "%s"' %output
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;@ Wayne, I didn't mention the da module because she mentioned she was on version 10.0 still...but as Chris said, the new .da cursors are waaaay faster! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;P.S. I need to limit my sugar intake while at work, feeling loopy...Happy scripting!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:24:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/403999#M31819</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T18:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract values from a field and write them to a text file using Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/404000#M31820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;For comparison.&amp;nbsp; run multiple times&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;took&amp;nbsp; 5.42300009727&amp;nbsp; seconds to run using cursors&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;took&amp;nbsp; 14.9790000916&amp;nbsp; seconds to run using Export_stats&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;took&amp;nbsp; 1.01900005341&amp;nbsp; seconds to run using da.searchcursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; ================================ RESTART ================================&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;took&amp;nbsp; 5.4279999733&amp;nbsp; seconds to run using cursors&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;took&amp;nbsp; 15.0590000153&amp;nbsp; seconds to run using Export_stats&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;took&amp;nbsp; 1.11499977112&amp;nbsp; seconds to run using da.searchcursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; ================================ RESTART ================================&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;took&amp;nbsp; 6.02999997139&amp;nbsp; seconds to run using cursors&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;took&amp;nbsp; 15.8759999275&amp;nbsp; seconds to run using Export_stats&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;took&amp;nbsp; 1.08899998665&amp;nbsp; seconds to run using da.searchcursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; ================================ RESTART ================================&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;took&amp;nbsp; 5.89599990845&amp;nbsp; seconds to run using cursors&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;took&amp;nbsp; 15.3450000286&amp;nbsp; seconds to run using Export_stats&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;took&amp;nbsp; 1.04600000381&amp;nbsp; seconds to run using da.searchcursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; ================================ RESTART ================================&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;took&amp;nbsp; 6.25199985504&amp;nbsp; seconds to run using cursors&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;took&amp;nbsp; 15.6540000439&amp;nbsp; seconds to run using Export_stats&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;took&amp;nbsp; 1.0609998703&amp;nbsp; seconds to run using da.searchcursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I find it interesting that using a single tool take so much longer...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 20:27:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/404000#M31820</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2013-07-11T20:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract values from a field and write them to a text file using Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/404001#M31821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;@Caleb, that's awesome!&amp;nbsp; ...and oh yeah, v10.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;@Rhett, good to know!!&amp;nbsp; Interesting indeed, figured it would take longer, but that's much slower than I assumed.&amp;nbsp; Nice comparison!&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 20:49:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/404001#M31821</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-07-11T20:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract values from a field and write them to a text file using Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/404002#M31822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Just for fun, while talking about efficiency, may as well make to as few lines as possible &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
fc = r'G:\Data\Geodatabase\Cedar_County.gdb\CADASTRAL\PARCEL'
output = r'C:\Users\GIS\Desktop\textfile.txt'

with open(output, 'w') as f:
&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write('\n'.join(r.PID for r in arcpy.SearchCursor(fc)))
print 'Created "%s"' %output
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;@ Wayne, I didn't mention the da module because she mentioned she was on version 10.0 still...but as Chris said, the new .da cursors are waaaay faster! &lt;BR /&gt;&lt;BR /&gt;P.S. I need to limit my sugar intake while at work, feeling loopy...Happy scripting!&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If only I could +10 you for using join()!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:24:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/404002#M31822</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-11T18:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to Extract values from a field and write them to a text file using Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/404003#M31823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If only I could +10 you for using join()!&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Well, I can only give you one for it, but done....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 23:53:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-extract-values-from-a-field-and-write-them/m-p/404003#M31823</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2013-07-11T23:53:47Z</dc:date>
    </item>
  </channel>
</rss>

