<?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: Use txt file as Fields in attribute table in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271735#M21000</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;output &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NewFires.shp"&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# ....&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CreateFeatureclass_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;work&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; output&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"POINT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get an error &lt;EM&gt;000354 : The name contains invalid characters &lt;/EM&gt;(a table in a file geodatabase cannot include a space or a period).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, you are using an Access database?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;work &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"C:\Scripts\Lab 7 Data\WildlandFires.mdb"&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 13:16:37 GMT</pubDate>
    <dc:creator>RandyBurton</dc:creator>
    <dc:date>2021-12-11T13:16:37Z</dc:date>
    <item>
      <title>Use txt file as Fields in attribute table</title>
      <link>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271724#M20989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am attempting to write a script so that instead of hardcoding the name of the new field as "CONFIVALUE" for the confidence value, I want to use the name of the third column in the header of the input text file.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For example, let's say that the first line of the input text file looks like this:&lt;/P&gt;&lt;P&gt;Latitude,Longitude,Confidence&lt;/P&gt;&lt;P&gt;In this case the field name should be "Confidence".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the first line looked like this:&lt;/P&gt;&lt;P&gt;Latitude,Longitude,ConfidValue&lt;/P&gt;&lt;P&gt;Then the field name should be "ConfidValue".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error if i have conField indexed as conField[2]:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "C:\Users\Aleah\Desktop\PythonScripts\Lab7_Q5.py", line 22, in &amp;lt;module&amp;gt;&lt;BR /&gt;IndexError: list index out of range&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The error i am receiving if i remove the index is:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "C:\Program Files (x86)\Wing IDE 101 4.1\src\debug\tserver\_sandbox.py", line 27, in &amp;lt;module&amp;gt;&lt;BR /&gt; File "C:\Program Files (x86)\ArcGIS\Desktop10.3\arcpy\arcpy\management.py", line 3246, in AddField&lt;BR /&gt; raise e&lt;BR /&gt;RuntimeError: Object: Error in executing tool&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; work = "C:\Scripts\Lab 7 Data\WildlandFires.mdb"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = work # Set the workspace to the geodatabase&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.overwriteOutput = True&lt;BR /&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iFile = "C:\Scripts\Lab 7 Data\NorthAmericaWildfires_2007275.txt" &lt;BR /&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output = "NewFires.shp"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; threshold = 99&lt;BR /&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f = open(iFile, 'r')# input text file C:\Scripts\Lab 7 Data\NorthAmericaWildfires_2007275.txt in "read" mode&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; lstFires = f.readlines() # Read the lines of fire &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conField = []&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for line in f:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; comma = line.split(',')&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conField = comma&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print conField[2]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; field = ["SHAPE@", conField[2]] # represents the field names for each row in the feature class&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Create Feature Class&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateFeatureclass_management(work, output, "POINT")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(output, conField[2], "FLOAT")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor_new = arcpy.da.InsertCursor(output, field)# add the new points that you will create to the "NewFires" feature class&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.close() # close the file &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del cursor_new # release the cursor lock on the feature class&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="315506" alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/315506_txt.file.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Feb 2017 19:59:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271724#M20989</guid>
      <dc:creator>AleahWorthem</dc:creator>
      <dc:date>2017-02-05T19:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Use txt file as Fields in attribute table</title>
      <link>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271725#M20990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Aleah, perhaps you can format your code &lt;A _jive_internal="true" href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;Code Formatting the Basics++&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2017 01:28:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271725#M20990</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-02-06T01:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: Use txt file as Fields in attribute table</title>
      <link>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271726#M20991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since "line 22" is generating the error, what exactly is line 22?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, does &lt;SPAN style="font-family: courier new,courier,monospace;"&gt;print conField[2]&lt;/SPAN&gt; print the result you expect?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2017 02:43:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271726#M20991</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2017-02-06T02:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: Use txt file as Fields in attribute table</title>
      <link>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271727#M20992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;comma &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; line&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;','&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
conField &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; comma
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; conField&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It appears to be a circular way around to splitting the line reference by the ',' then slicing it to get the last entry, it would be just as well be done as&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;conField&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; line&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;','&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:16:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271727#M20992</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T13:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: Use txt file as Fields in attribute table</title>
      <link>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271728#M20993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;conField = []&lt;BR /&gt;for line in f:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conField = line.split(',')[2]&lt;BR /&gt; &lt;BR /&gt;field = ["SHAPE@", conField] # represents the field names for each row in the feature class&lt;BR /&gt;# Process: Create Feature Class&lt;/P&gt;&lt;P&gt;arcpy.CreateFeatureclass_management(work, output, "POINT")&lt;/P&gt;&lt;P&gt;arcpy.AddField_management(output, conField, "FLOAT")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "C:\Program Files (x86)\Wing IDE 101 4.1\src\debug\tserver\_sandbox.py", line 25, in &amp;lt;module&amp;gt;&lt;BR /&gt; File "C:\Program Files (x86)\ArcGIS\Desktop10.3\arcpy\arcpy\management.py", line 3246, in AddField&lt;BR /&gt; raise e&lt;BR /&gt;RuntimeError: Object: Error in executing tool&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2017 17:16:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271728#M20993</guid>
      <dc:creator>AleahWorthem</dc:creator>
      <dc:date>2017-02-06T17:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: Use txt file as Fields in attribute table</title>
      <link>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271729#M20994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV class=""&gt;&lt;P&gt;conField = []&lt;BR /&gt;for line in f:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conField = line.split(',')[2]&lt;BR /&gt; &lt;BR /&gt;field = ["SHAPE@", conField] # represents the field names for each row in the feature class&lt;BR /&gt;# Process: Create Feature Class&lt;/P&gt;&lt;P&gt;arcpy.CreateFeatureclass_management(work, output, "POINT")&lt;/P&gt;&lt;P&gt;arcpy.AddField_management(output, conField, "FLOAT")&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "C:\Program Files (x86)\Wing IDE 101 4.1\src\debug\tserver\_sandbox.py", line 25, in &amp;lt;module&amp;gt;&lt;BR /&gt; File "C:\Program Files (x86)\ArcGIS\Desktop10.3\arcpy\arcpy\management.py", line 3246, in AddField&lt;BR /&gt; raise e&lt;BR /&gt;RuntimeError: Object: Error in executing tool&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2017 17:16:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271729#M20994</guid>
      <dc:creator>AleahWorthem</dc:creator>
      <dc:date>2017-02-06T17:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: Use txt file as Fields in attribute table</title>
      <link>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271730#M20995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I assume that since you read all lines into the list, setting conField[2] to the third value in each line will ultimately result in the final value of your file, not the field name from the first line. You can access the first line of the file with f.readline() (reads only one line) or f.readlines()[0].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, you may be running into a problem if Python is reading a new line character at the end of your line. Try printing the split list to see the new line character:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; f &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; open&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;'C:\junk\log.txt'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'r'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; my_list &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; f&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;readlines&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; my_list&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; my_list&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;','&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; 
field1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;field2&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;field3

&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'field1'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'field2'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'field3\n'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:16:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271730#M20995</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-11T13:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: Use txt file as Fields in attribute table</title>
      <link>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271731#M20996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As Dan suggested, please use code formatting,&amp;nbsp; It makes it easier for people to read and for specific comments about the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your first line, &lt;SPAN style="font-family: courier new,courier,monospace;"&gt;cornfield = []&lt;/SPAN&gt;, is unnecessary because &lt;SPAN style="font-family: courier new,courier,monospace;"&gt;str.split()&lt;/SPAN&gt; returns a list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are using file.readlines(), emphasis on plural, that reads "until EOF."&amp;nbsp; In your loop:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; line &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; f&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conField &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; line&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;','&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You are looping through the entire file contents, and by the time the loop finishes, &lt;SPAN style="font-family: courier new,courier,monospace;"&gt;conField&lt;/SPAN&gt; contains the last line, not the first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you put a print statement after the loop is complete, what values are stored in &lt;SPAN style="font-family: courier new,courier,monospace;"&gt;conField&lt;/SPAN&gt;?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:16:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271731#M20996</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T13:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Use txt file as Fields in attribute table</title>
      <link>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271732#M20997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;f = open(iFile, 'r')# input text file C:\Scripts\Lab 7 Data\NorthAmericaWildfires_2007275.txt in "read" mode&lt;/P&gt;&lt;P&gt;lstFires = f.readlines() # Read the first lines of file&lt;/P&gt;&lt;P&gt;print (lstFires[0])&lt;BR /&gt;print (lstFires[0].strip().split(','))&lt;BR /&gt;This gives me :&lt;/P&gt;&lt;P&gt;Latitude,Longitude,Confidence&lt;/P&gt;&lt;P&gt;['Latitude', 'Longitude', 'Confidence']&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But how can I access the Confidence string only, to be used later in arcpy.AddField_management&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2017 17:59:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271732#M20997</guid>
      <dc:creator>AleahWorthem</dc:creator>
      <dc:date>2017-02-06T17:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Use txt file as Fields in attribute table</title>
      <link>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271733#M20998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;con_val = lstFires[0].strip().split(',')[-1]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2017 18:30:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271733#M20998</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-02-06T18:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: Use txt file as Fields in attribute table</title>
      <link>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271734#M20999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So, now that you've got rid of the new line character using strip(), you can access it similar to how you were doing it before, using the [2] index:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;lstFires&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strip&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;','&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2017 18:33:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271734#M20999</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2017-02-06T18:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Use txt file as Fields in attribute table</title>
      <link>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271735#M21000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;output &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NewFires.shp"&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# ....&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CreateFeatureclass_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;work&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; output&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"POINT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get an error &lt;EM&gt;000354 : The name contains invalid characters &lt;/EM&gt;(a table in a file geodatabase cannot include a space or a period).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, you are using an Access database?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;work &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"C:\Scripts\Lab 7 Data\WildlandFires.mdb"&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:16:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271735#M21000</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-11T13:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Use txt file as Fields in attribute table</title>
      <link>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271736#M21001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H2&gt;Syntax&lt;/H2&gt;&lt;DIV class=""&gt;CreateFeatureclass_management (out_path, out_name, {geometry_type}, {template}, {has_m}, {has_z}, {spatial_reference}, {config_keyword}, {spatial_grid_1}, {spatial_grid_2}, {spatial_grid_3})&lt;/DIV&gt;&lt;DIV class=""&gt; &lt;/DIV&gt;&lt;DIV class=""&gt;the MDB seems to be working&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2017 19:43:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-txt-file-as-fields-in-attribute-table/m-p/271736#M21001</guid>
      <dc:creator>AleahWorthem</dc:creator>
      <dc:date>2017-02-06T19:43:44Z</dc:date>
    </item>
  </channel>
</rss>

