<?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: Write records to csv in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553461#M43231</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I figured out the cause, or at least I got past it.&amp;nbsp; The Parcels layer I was working with was Joined to another table.&amp;nbsp; Once I removed the join, it ran as expected.&amp;nbsp; Even though I wasn't referencing any joined fields...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Dec 2011 16:45:32 GMT</pubDate>
    <dc:creator>DaveJordan1</dc:creator>
    <dc:date>2011-12-02T16:45:32Z</dc:date>
    <item>
      <title>Write records to csv</title>
      <link>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553448#M43218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My ultimate goal is to create mailing labels from selected parcel polygons. using the following code I am attempting to write out to a txt file the selected records. It works but I am having issues with the output it is giving me. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) before each field that contains a string value it is inserting the letter "u". &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) I want to remove the quotes from each field and the brackets.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3) If there is a better way to do this, please let me know&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the code followed by a sample of the output&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-----------------------------------------------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; mxd = arcpy.mapping.MapDocument("Current")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; df = arcpy.mapping.ListDataFrames(mxd, "ParcelDF")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Parcels = "parcels"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; fc = arcpy.mapping.ListLayers(mxd, Parcels, df)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; f = open("Y:\Notification Radius Pkgs\Setup10\Test.txt", 'w')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; # Create a search cursor &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; rows = arcpy.SearchCursor(fc) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; # Create a list of fields&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; fields = arcpy.ListFields(fc, "", "")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; # Write the output to a text file&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; record = [""]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; for row in rows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; for field in fields: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if field.type != "Geometry":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; #print "%s: Value = %s" % (field.name, row.getValue(field.name))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; record.append(row.getValue(field.name))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; f.writelines("%s\n" % record)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; record = [""]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; f.close-------------------------------------------------------------------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SAMPLE OUTPUT&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[' ', 27521, u'24', u'37', u'22', u'01', u'B', u'7', 0, u' ', u' ', 0.59999999999999998]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Nov 2011 12:23:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553448#M43218</guid>
      <dc:creator>DaveJordan1</dc:creator>
      <dc:date>2011-11-28T12:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: Write records to csv</title>
      <link>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553449#M43219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Dave,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can do this by iterating through each item in your list.&amp;nbsp; Add the following to your script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env

mxd = arcpy.mapping.MapDocument("Current")
df = arcpy.mapping.ListDataFrames(mxd, "ParcelDF")[0]
Parcels = "parcels"
fc = arcpy.mapping.ListLayers(mxd, Parcels, df)[0]

f = open("Y:\Notification Radius Pkgs\Setup10\Test.txt", 'w')

rows = arcpy.SearchCursor(fc, "OBJECTID &amp;lt; 5")

fields = arcpy.ListFields(fc)

record = []
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in fields:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if field.type != "Geometry":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ##print "%s: Value = %s" % (field.name, row.getValue(field.name))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; record.append(row.getValue(field.name))
&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for item in record:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.writelines("%s\n" % item)&lt;/STRONG&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; record = []

f.close()
del row, rows&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:55:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553449#M43219</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T23:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Write records to csv</title>
      <link>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553450#M43220</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for taking time to look at this.&amp;nbsp; Your suggestion does clean up the output, but it prints each field value in the record to a newline.&amp;nbsp; I need each value to be separated by a comma and each record to a newline...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;example:&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;24, 37,&amp;nbsp; 22', 01, B, 7, 0, , , 0.59999999999999998&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;24, 37,&amp;nbsp; 22', 01, B, 8, 0, , , 0.59999999999999998&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;24, 37,&amp;nbsp; 22', 01, B, 9, 0, , , 0.59999999999999998&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Nov 2011 19:10:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553450#M43220</guid>
      <dc:creator>DaveJordan1</dc:creator>
      <dc:date>2011-11-28T19:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Write records to csv</title>
      <link>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553451#M43221</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There may be an easier way, but I was able to accomplish this by writing each field to the output text file.&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env

mxd = arcpy.mapping.MapDocument("Current")
df = arcpy.mapping.ListDataFrames(mxd, "ParcelDF")[0]
Parcels = "parcels"
fc = arcpy.mapping.ListLayers(mxd, Parcels, df)[0]

f = open("Y:\Notification Radius Pkgs\Setup10\Test.txt", 'w')

rows = arcpy.SearchCursor(fc)

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write(str(row.getValue("OBJECTID")) + ", " + str(row.getValue("LU_CODE")) + ", " + str(row.getValue("ZONE_CODE")) + "\n")

f.close()
del row, rows&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:55:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553451#M43221</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T23:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: Write records to csv</title>
      <link>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553452#M43222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jake,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've spent the better part of the day trying to get this to work.&amp;nbsp; I keep thinking that I must be missing something.&amp;nbsp; Its failing on the WRITE statement.&amp;nbsp; I've simplified it down to just a single field (OBJECTID) for testing.&amp;nbsp;&amp;nbsp; Here is the error I am getting:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Running script Test...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Dev\ArcGIS10\Python\DaveTest.py", line 44, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write(str(row.getValue("OBJECTID")) + "\n")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\arcobjects.py", line 945, in getValue&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return convertArcObjectToPythonObject(self._arc_object.GetValue(*gp_fixargs(args)))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RuntimeError: ERROR 999999: Error executing function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 999999: Error executing function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Completed script Test...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Test).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2011 18:38:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553452#M43222</guid>
      <dc:creator>DaveJordan</dc:creator>
      <dc:date>2011-11-30T18:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Write records to csv</title>
      <link>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553453#M43223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Dave, I tested Jake's script and it works fine for me. Are you using proper syntax/indentation? Is there a field called "OBJECTID"? Do you have write access to that directory on Y-drive? Not sure what would be causing this issue.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try something simple like &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
rows = arcpy.SearchCursor("parcels")
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print row.getValue("OBJECTID")
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Then add on line by line until you run into a wall.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:55:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553453#M43223</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T23:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Write records to csv</title>
      <link>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553454#M43224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Dave,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Feel free to post your entire block of code.&amp;nbsp; Be sure to wrap it in &lt;PRE&gt; tags (using # symbol above) to preserve indentation.&lt;/PRE&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2011 19:09:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553454#M43224</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2011-11-30T19:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: Write records to csv</title>
      <link>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553455#M43225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is the entire code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
from arcpy import env
try:
&amp;nbsp; mxd = arcpy.mapping.MapDocument("Current")
&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd, "ParcelDF")[0]
&amp;nbsp; Parcels = "parcels"
&amp;nbsp; fc = arcpy.mapping.ListLayers(mxd, Parcels, df)[0]
&amp;nbsp; f = open("Y:\Notification Radius Pkgs\Setup10\Test.txt", 'w')

&amp;nbsp; # Create a list of fields
&amp;nbsp; fields = arcpy.ListFields(fc, "", "")

&amp;nbsp; # Create a search cursor 
&amp;nbsp; rows = arcpy.SearchCursor(fc,"","","TOWNSHIP; RANGE; SEC; SUBCODE; BLOCK; LOT","") 


&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("OBJECTID")) + "\n")
# Previous attempts-
#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.writelines(str(row.getValue("TOWNSHIP")) + ", " + "\n")
#&amp;nbsp; (row.getValue("TOWNSHIP") + ", " str(row.getValue("RANGE")) + ", " + str(row.getValue("SEC")) + ", " + str(row.getValue("SUBCODE")) + ", " + str(row.getValue("BLOCK")) + ", " + str(row.getValue("LOT")) + "\n")


&amp;nbsp; f.close()
&amp;nbsp; del row, rows 

except Exception, e:
&amp;nbsp; import traceback
&amp;nbsp; f.close
&amp;nbsp; map(arcpy.AddError, traceback.format_exc().split("\n"))
&amp;nbsp; arcpy.AddError(str(e))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:55:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553455#M43225</guid>
      <dc:creator>DaveJordan1</dc:creator>
      <dc:date>2021-12-11T23:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Write records to csv</title>
      <link>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553456#M43226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Oh, your field limiters are taking out OBJECTID...&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;rows = arcpy.SearchCursor(fc,"","","TOWNSHIP; RANGE; SEC; SUBCODE; BLOCK; LOT","") &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Oh sorry, after testing even that should work, I guess OBJECTID is protected from field limiters. Not sure what your issue is, works fine even with the non raw path and improper indentation.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Dec 2011 19:18:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553456#M43226</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2011-12-01T19:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: Write records to csv</title>
      <link>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553457#M43227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Dave, I tested Jake's script and it works fine for me. Are you using proper syntax/indentation? Is there a field called "OBJECTID"? Do you have write access to that directory on Y-drive? Not sure what would be causing this issue.&lt;BR /&gt;&lt;BR /&gt;Try something simple like &lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
rows = arcpy.SearchCursor("parcels")
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print row.getValue("OBJECTID")
&lt;/PRE&gt;&lt;BR /&gt;Then add on line by line until you run into a wall.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried your sample also.&amp;nbsp; It gives the same 99999 useless error.&amp;nbsp; I believe I am using the proper indentation.&amp;nbsp; Yes there is a field called OBJECTID and yes I have write permission to the directory.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Extra info - I have kept it simple for development purposes, There is only one data frame and one feature class (parcels) in this mxd.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have successfully written out individual values from fields in the row using - For Field in Fields -&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for helping with this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:55:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553457#M43227</guid>
      <dc:creator>DaveJordan1</dc:creator>
      <dc:date>2021-12-11T23:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Write records to csv</title>
      <link>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553458#M43228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you are failing on this, &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rows = arcpy.SearchCursor("parcels")
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print row.getValue("OBJECTID")&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;and "parcels" is a valid feature layer with OBJECTID as a field, you have some other environment problems outside of your code. Try rebooting your computer and running it again.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:55:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553458#M43228</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T23:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Write records to csv</title>
      <link>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553459#M43229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Oh, your field limiters are taking out OBJECTID...&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;rows = arcpy.SearchCursor(fc,"","","TOWNSHIP; RANGE; SEC; SUBCODE; BLOCK; LOT","") &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Oh sorry, after testing even that should work, I guess OBJECTID is protected from field limiters. Not sure what your issue is, works fine even with the non raw path and improper indentation.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, I added OBJECTID in and it still fails.&amp;nbsp; I think my next step is to start all over with a clean script...&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I 've tried so many different approaches...&amp;nbsp; Is'nt the measure of insanity something like, "One's tendancy to perform the same act over and over again, hoping for different results, regardless of the fact that the results are constant"...or something like that!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Dec 2011 19:35:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553459#M43229</guid>
      <dc:creator>DaveJordan1</dc:creator>
      <dc:date>2011-12-01T19:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Write records to csv</title>
      <link>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553460#M43230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That's Einstein's definition yes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try to copy and paste this in the ArcMap python window after a reboot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument("Current")
&amp;nbsp;&amp;nbsp;&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; Parcels = "parcels"
&amp;nbsp;&amp;nbsp;&amp;nbsp; fc = arcpy.mapping.ListLayers(mxd, Parcels, df)[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; f = open(r"Y:\Notification Radius Pkgs\Setup10\Test\Test.txt", 'w')

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create a search cursor
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.SearchCursor(fc)
&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("OBJECTID")) + "\n")

&amp;nbsp;&amp;nbsp;&amp;nbsp; f.close()
&amp;nbsp;&amp;nbsp;&amp;nbsp; del row, rows

except Exception, e:
&amp;nbsp;&amp;nbsp;&amp;nbsp; import traceback
&amp;nbsp;&amp;nbsp;&amp;nbsp; f.close
&amp;nbsp;&amp;nbsp;&amp;nbsp; map(arcpy.AddError, traceback.format_exc().split("\n"))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(str(e))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:55:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553460#M43230</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T23:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: Write records to csv</title>
      <link>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553461#M43231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I figured out the cause, or at least I got past it.&amp;nbsp; The Parcels layer I was working with was Joined to another table.&amp;nbsp; Once I removed the join, it ran as expected.&amp;nbsp; Even though I wasn't referencing any joined fields...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 16:45:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553461#M43231</guid>
      <dc:creator>DaveJordan1</dc:creator>
      <dc:date>2011-12-02T16:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: Write records to csv</title>
      <link>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553462#M43232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Dave,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When a join exists, the field name will change to 'feature class/table name.field name'.&amp;nbsp; So when calling the fields to write to the text file you would need to specify the parcel feature class name.&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;f.write(str(row.getValue("parcels.OBJECTID")) + ", " + str(row.getValue("parcels.LU_CODE")) + ", " + str(row.getValue("parcels.ZONE_CODE")) + "\n")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2011 12:27:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/write-records-to-csv/m-p/553462#M43232</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2011-12-05T12:27:15Z</dc:date>
    </item>
  </channel>
</rss>

