<?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: Scripts to convert text file to polygon. in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/scripts-to-convert-text-file-to-polygon/m-p/481882#M1633</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: clthompson&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm also confused, these look like individual points, not the verticies along the boundary of a traverse that might describe a stand or a plot.&amp;nbsp; The easiest thing you could do with those is to create an XY theme, and then use select by attribute combined with the field calculator to make some of the adjustments, and then copy the rows the of the event theme into a new shapefile.&amp;nbsp; This will create a &lt;/SPAN&gt;&lt;STRONG&gt;point&lt;/STRONG&gt;&lt;SPAN&gt; shapefile for you attributed with the column headers you specified.&amp;nbsp; Can you clarify the point versus polygon issue?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Oct 2012 14:45:13 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2012-10-24T14:45:13Z</dc:date>
    <item>
      <title>Scripts to convert text file to polygon.</title>
      <link>https://community.esri.com/t5/transportation-questions/scripts-to-convert-text-file-to-polygon/m-p/481877#M1628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am try to learn python and need to deal with the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;At the end of each day the two foresters upload the gps data to you by ftp so you can process and re-format the data. The data comes to you as a text file (AS.txt and SB.txt). The text file field columns are: ID, Common Name, Diameter at Breast Height (DBH), Staff, Longitude, &amp;amp; Latitude. There are some errors within the data that need fixed:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;â?¢ Spelling errors within Common Name field â?? here all names should be spelled correctly and capitalized.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;â?¢ DBH 0 values â?? for collector AS a DBH of 0 should be changed to 14, AND for collector SB a DBH of 0 should be changed to 16.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Develop a script or set of scripts to automate the quality control and re-formatting steps. If you can help I can send the text files. I am trying to put together the complete script syntax.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am having a tough time gathering the scripts I need.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Oct 2012 14:14:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/scripts-to-convert-text-file-to-polygon/m-p/481877#M1628</guid>
      <dc:creator>DanielWebb1</dc:creator>
      <dc:date>2012-10-22T14:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: Scripts to convert text file to polygon.</title>
      <link>https://community.esri.com/t5/transportation-questions/scripts-to-convert-text-file-to-polygon/m-p/481878#M1629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: mzcoyle&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You want to convert this data to a polygon? That doesn't make much sense to me since you would lose all this data you are trying to format.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Since your data doesn't have column headers it makes it a little trickier. You could add them to your csv file first and do the rest of your formatting there, and then load it directly, or you could create an empty feature class using your known columns and load the data then format it there.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Oct 2012 14:36:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/scripts-to-convert-text-file-to-polygon/m-p/481878#M1629</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-10-22T14:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Scripts to convert text file to polygon.</title>
      <link>https://community.esri.com/t5/transportation-questions/scripts-to-convert-text-file-to-polygon/m-p/481879#M1630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;From what I am told this is the steps of code I need to do this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Create new shapefile that adds columns ID, DBH, Staff, Lattitude, Longitude. Name shapefile.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Prompting file to use.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Adding data from pulled file to new shapefile.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. Correct spelling in common Fieldname, prompt for correction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5. If staff = as, and = 0, change value to 14&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6. If staff = SB, and DBH = 0, change value to 16&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;7. merge to master shapefile.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Does this make sense or am I not seeing something here? I am learning this so all help is appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Oct 2012 16:08:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/scripts-to-convert-text-file-to-polygon/m-p/481879#M1630</guid>
      <dc:creator>DanielWebb1</dc:creator>
      <dc:date>2012-10-22T16:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: Scripts to convert text file to polygon.</title>
      <link>https://community.esri.com/t5/transportation-questions/scripts-to-convert-text-file-to-polygon/m-p/481880#M1631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: mzcoyle&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This should get you started. You will want to create a script or function to create a template feature class if one does not exist, depending on if you want to make that a part of the code or as a separate process. The rest of the steps are pretty straight forward. You can create a list or dictionary of words and test against the list to see if they match.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import csv
import os
import arcpy

def main(input_csv, output_shapefile):

&amp;nbsp;&amp;nbsp;&amp;nbsp; workspace = r"C:\temp\py_temp"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = workspace
&amp;nbsp;&amp;nbsp;&amp;nbsp; shapefile = r"C:\temp\py_temp\import_template.shp"

&amp;nbsp;&amp;nbsp;&amp;nbsp; out_path = workspace
&amp;nbsp;&amp;nbsp;&amp;nbsp; out_name = output_shapefile
&amp;nbsp;&amp;nbsp;&amp;nbsp; geometry = "POINT"
&amp;nbsp;&amp;nbsp;&amp;nbsp; template = shapefile
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateFeatureclass_management(out_path, out_name, geometry, template)

&amp;nbsp;&amp;nbsp;&amp;nbsp; i_curs = arcpy.InsertCursor(out_name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; with open(input_csv, "rb") as csvfile:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; open_reader = csv.reader(csvfile, delimiter=',')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for blank, id, Name, DBH, Staff, Longitude, Latitude in open_reader:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i_row = i_curs.newRow()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i_row.ID = id
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Name = Name.capitalize()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i_row.Name = Name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i_row.DBH = DBH
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i_row.Staff = Staff
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i_row.Longitude = Longitude
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i_row.Latitude = Latitude
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i_curs.insertRow(i_row)

&amp;nbsp;&amp;nbsp;&amp;nbsp; del open_reader
&amp;nbsp;&amp;nbsp;&amp;nbsp; del i_curs
&amp;nbsp;&amp;nbsp;&amp;nbsp; del i_row

&amp;nbsp;&amp;nbsp;&amp;nbsp; print "done"

if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; csv_file = r"C:\temp\py_temp\SB.txt"
&amp;nbsp;&amp;nbsp;&amp;nbsp; shp_name = "shapefile2.shp"
&amp;nbsp;&amp;nbsp;&amp;nbsp; main(csv_file, shp_name)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: Here is a very simple name check test. This simply assumes if the first letter matches the first letter in the list of tree types then that is the one to use. If you eventually have a list of tree types that have the same first letter you may want to make this more robust.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; name_list = ["Ash", "Dogwood", "Hickory", "Maple", "Oak"]
&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; Name = Name.capitalize()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if Name not in name_list:
&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; for name_proper in name_list:
&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; if Name.startswith(name_proper[0]):
&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;&amp;nbsp;&amp;nbsp; Name = name_proper
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i_row.Name = Name&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:15:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/scripts-to-convert-text-file-to-polygon/m-p/481880#M1631</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T21:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: Scripts to convert text file to polygon.</title>
      <link>https://community.esri.com/t5/transportation-questions/scripts-to-convert-text-file-to-polygon/m-p/481881#M1632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;For the name matching you could also try difflib.getclosematches()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import difflib
...
Name = difflib.get_close_matches(Name, ["Ash", "Hickory", "Oak", "Dogwood", "Maple"])[0]&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:15:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/scripts-to-convert-text-file-to-polygon/m-p/481881#M1632</guid>
      <dc:creator>RaphaelR</dc:creator>
      <dc:date>2021-12-11T21:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Scripts to convert text file to polygon.</title>
      <link>https://community.esri.com/t5/transportation-questions/scripts-to-convert-text-file-to-polygon/m-p/481882#M1633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: clthompson&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm also confused, these look like individual points, not the verticies along the boundary of a traverse that might describe a stand or a plot.&amp;nbsp; The easiest thing you could do with those is to create an XY theme, and then use select by attribute combined with the field calculator to make some of the adjustments, and then copy the rows the of the event theme into a new shapefile.&amp;nbsp; This will create a &lt;/SPAN&gt;&lt;STRONG&gt;point&lt;/STRONG&gt;&lt;SPAN&gt; shapefile for you attributed with the column headers you specified.&amp;nbsp; Can you clarify the point versus polygon issue?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Oct 2012 14:45:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/scripts-to-convert-text-file-to-polygon/m-p/481882#M1633</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-10-24T14:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: Scripts to convert text file to polygon.</title>
      <link>https://community.esri.com/t5/transportation-questions/scripts-to-convert-text-file-to-polygon/m-p/481883#M1634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok I have clarity now. There is no polygon, just points. Also, this project is done in Modelbuilder, which creates the python script and usable text files. Thanks to all that helped.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 03:01:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/scripts-to-convert-text-file-to-polygon/m-p/481883#M1634</guid>
      <dc:creator>DanielWebb1</dc:creator>
      <dc:date>2012-10-25T03:01:04Z</dc:date>
    </item>
  </channel>
</rss>

