<?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: [Arcmap10]python script to add and populate a field for several shapefiles in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344367#M26989</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It finally worked...the only thing is that the date written in the file is not the one expected..&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;it is writting the same numer in all files in the form 18991230...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;don't really know what is hapening...but it worked well when I used the function to automatically print the actual date...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Oct 2011 09:06:12 GMT</pubDate>
    <dc:creator>yoanndrocourt</dc:creator>
    <dc:date>2011-10-21T09:06:12Z</dc:date>
    <item>
      <title>[Arcmap10]python script to add and populate a field for several shapefiles</title>
      <link>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344361#M26983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi every one,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm realy new to python scripting, and I'm trying to write a script allowing me to create a shp file from a txt file, then add a new field to it and then fill this new field with a value extracted from the name of the file...this for several hundreds of txt files...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have put together several bit of script but I can't get it to work...for some reason it stopped at the stage of creating the feature "arcpy.CreateFeaturesFromTextFile_samples"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;could any one help me, that would be much appriciated&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ps ; the script in attached to this post&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;best regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yoann&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2011 13:07:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344361#M26983</guid>
      <dc:creator>yoanndrocourt</dc:creator>
      <dc:date>2011-10-18T13:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: [Arcmap10]python script to add and populate a field for several shapefiles</title>
      <link>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344362#M26984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What sort of error did you receive when running the script?&amp;nbsp; This will help pinpoint the problem.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2011 13:52:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344362#M26984</guid>
      <dc:creator>ChristopherStorer</dc:creator>
      <dc:date>2011-10-18T13:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: [Arcmap10]python script to add and populate a field for several shapefiles</title>
      <link>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344363#M26985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;thank really for your help &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;it's the same error than in my other message...it has to do with the toolbox I think..&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cause it print the date extracted from the file, the txt name and shp name,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and then crashes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but I don't really know what else I can do..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;22/06/2008&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ASA_APM_1PNPDK20080622_131859_000000442069_00382_33001_1771_ok.shp&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ASA_APM_1PNPDK20080622_131859_000000442069_00382_33001_1771_ok.txt&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;got to here&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;An unknown error occurred:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;F:\front\create_feature_from_txt_batch_script3.py:63: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Object: Tool or environment &amp;lt;????????????????????&amp;gt; not found&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2011 14:24:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344363#M26985</guid>
      <dc:creator>yoanndrocourt</dc:creator>
      <dc:date>2011-10-18T14:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: [Arcmap10]python script to add and populate a field for several shapefiles</title>
      <link>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344364#M26986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Give this version of your script a try.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The tool "CreateFeaturesFromTextFile_samples" has been depreciated meaning that the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;"functionality has been replaced by other tools"&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But the tool is still there in Arc10, it's just hidden so you can still access it from python through gp.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I didn't test the script, but you should be able to at least access that tool now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#------------------------------------------------------------------------------------------------
#------------------------- script to create features from txt file ------------------------
#------------------------------------------------------------------------------------------------

# Create geoprocessing dispatch object
import arcgisscripting, glob
gp = arcgisscripting.create() # allow you to access the geoprocessing tools in arcgis

#------------------------------------------------------------------------------------------------
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; outdir = "F:\\front\\trash"
&amp;nbsp;&amp;nbsp;&amp;nbsp; filePaths = glob.glob("F:\\front\\trash\\*_ok.txt")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print filePaths

&amp;nbsp;&amp;nbsp;&amp;nbsp; for filePath in filePaths:

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inTxt = filePath[15:]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inSep = "local decimal point" 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shpFile = filePath[15:-7] + "_ok.shp" #outdir +
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shpFile_Ok = shpFile
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldVal = shpFile[20:22] + "/" + shpFile[18:20] + "/" + shpFile[14:18]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fieldVal
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print shpFile
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print inTxt
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'got to here'
&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; # Run tool
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.CreateFeaturesFromTextFile_samples(inTxt, inSep , shpFile, \
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "PROJCS['Polar Stereographic', GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984', \
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPHEROID['WGS_1984',6378137.0,298.257223563]], PRIMEM['Greenwich',0.0], \
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UNIT['Degree',0.0174532925199433]],PROJECTION['Stereographic_North_Pole'], \
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-45.0], \
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PARAMETER['Standard_Parallel_1',71.0], UNIT['Meter',1.0]] \
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;-30636100 -30636100 147003033.263715;-100000 10000;-100000 10000;0.001;0.001;0.001; IsHighPrecision")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'Got to there...'

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Add Field
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddField_management(shpFile, "date", "DATE", "", "", "", "", "NON_NULLABLE", "NON_REQUIRED", "")&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Calculate Field
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.CalculateField_management(shpFile_ok, "date", "fieldVal", "PYTHON_9.3", "")

except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print gp.GetMessages() # allows to get error message when they happen&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:13:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344364#M26986</guid>
      <dc:creator>RDHarles</dc:creator>
      <dc:date>2021-12-11T16:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: [Arcmap10]python script to add and populate a field for several shapefiles</title>
      <link>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344365#M26987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thank you so much for your reply, yes it is working kind of better...now the problem is when it has to write the value "fieldVal" in the field...when I open the resulting dbf file...the value is not the one expected...and it only work for the first file of the directory and then crashes...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but thanks for this reply...it helped me a lot already&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yoann&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Oct 2011 14:46:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344365#M26987</guid>
      <dc:creator>yoanndrocourt</dc:creator>
      <dc:date>2011-10-20T14:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: [Arcmap10]python script to add and populate a field for several shapefiles</title>
      <link>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344366#M26988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What does the error message look like?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Oct 2011 14:53:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344366#M26988</guid>
      <dc:creator>RDHarles</dc:creator>
      <dc:date>2011-10-20T14:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: [Arcmap10]python script to add and populate a field for several shapefiles</title>
      <link>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344367#M26989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It finally worked...the only thing is that the date written in the file is not the one expected..&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;it is writting the same numer in all files in the form 18991230...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;don't really know what is hapening...but it worked well when I used the function to automatically print the actual date...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Oct 2011 09:06:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344367#M26989</guid>
      <dc:creator>yoanndrocourt</dc:creator>
      <dc:date>2011-10-21T09:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: [Arcmap10]python script to add and populate a field for several shapefiles</title>
      <link>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344368#M26990</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;SPAN&gt;I am still strugling to write in the newly created field a date extracted from the name of a file..&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I did manage to extract corectly the date in the form yyyy-mm-dd, however when I opens the attribute table in arcmap, a different date appears (for example it should be 22/06/2008 but instead I get 02/06/1905)...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;each new shapefile have a different date, but not the one expected...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;any idea, why would that happens???&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;any help would be very much appreciated...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Oct 2011 14:29:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344368#M26990</guid>
      <dc:creator>yoanndrocourt</dc:creator>
      <dc:date>2011-10-24T14:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: [Arcmap10]python script to add and populate a field for several shapefiles</title>
      <link>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344369#M26991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Remove the quotes around fieldVal in the CalculateField_management line. It's a variable, not a string (yes, the variable CONTAINS a string, but in order for you to get the value of the variable, it must read it as a variable and not as the character positions of the string input). Like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Process: Calculate Field
gp.CalculateField_management(shpFile_ok, "date", fieldVal, "PYTHON_9.3", "")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:13:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344369#M26991</guid>
      <dc:creator>RuthEmerick</dc:creator>
      <dc:date>2021-12-11T16:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: [Arcmap10]python script to add and populate a field for several shapefiles</title>
      <link>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344370#M26992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I got it working,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but thanks for your help anyway,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cheers&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Nov 2011 14:15:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap10-python-script-to-add-and-populate-a-field/m-p/344370#M26992</guid>
      <dc:creator>yoanndrocourt</dc:creator>
      <dc:date>2011-11-03T14:15:43Z</dc:date>
    </item>
  </channel>
</rss>

