<?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: ArcGis reading field as integer when it should be string. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332990#M25947</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you Kim Ollivier- I forgot all about that, think that counts as having learned something new today.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;By the way, I used some of your python script samples - for example, not sure off the top of my head where I found it, but used something you wrote to recalc DDP index grid page angles...good show, nice attention to detail!&amp;nbsp; (I pondered over your comment 'careful with up' - I got that after running an experimental strip around 'steep curves' and watched the angle measure 'flop'.&amp;nbsp; Sometimes 'up' is 'down'.)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Nov 2012 12:53:44 GMT</pubDate>
    <dc:creator>T__WayneWhitley</dc:creator>
    <dc:date>2012-11-08T12:53:44Z</dc:date>
    <item>
      <title>ArcGis reading field as integer when it should be string.</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332985#M25942</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;I am trying to read in a .txt (tab delimited) file using a python script and ArcGIS 10.1:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SCRB_ZIP_5_CD SCRB_ZIP_4_CD SCRB_ZIP_3_CD SCRB_ST_CD COUNTY_FIPS_CD LAT_DEG LNG_DEG NEW_RECORD_IND ID&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"02916" "1245" "703" "RI" "44007" 41.843590 -71.349532 "N" 50&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The first field, SCRB_ZIP_5_CD, should be a string, however it is being read as an integer and dropping the leading zero, is there a workaround to read this field as a string?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Frank&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 18:36:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332985#M25942</guid>
      <dc:creator>FrankChin</dc:creator>
      <dc:date>2012-11-07T18:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGis reading field as integer when it should be string.</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332986#M25943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you convert the value to a string before using it in the script?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;str(field value) will return the value as type string.&amp;nbsp; You can create a variable to equal the string value then use the variable in the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris B.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 20:36:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332986#M25943</guid>
      <dc:creator>ChristopherBlinn1</dc:creator>
      <dc:date>2012-11-07T20:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGis reading field as integer when it should be string.</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332987#M25944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Interesting...not sure and I don't remember offhand without testing, but if you read the line into a python list, does this behavior exhibit?&amp;nbsp; Or can you read directly into a text variable, something like var = '' (not var = 0), then load the variable, and print it.&amp;nbsp; Also, if you're allowed, it may suffice to to format your input file, quoting the vals that are meant to be text.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 21:01:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332987#M25944</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2012-11-07T21:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGis reading field as integer when it should be string.</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332988#M25945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You have not specified how you are reading in the text file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you had a look at the schema.ini specification? This is a Microsoft standard for defining the schema for reading in text files.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It works really well for loading text files into a geodatabase table because you can rename, set input widths, types to make the simple table to table tool work very well. This avoids a lot of complex coding opening a file and unpicking the components.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you have a table in a database try exporting it as a txt file and at 10.x a schema.ini file will be generated for you. Then keep the file with the source, edit the name and hey presto a schema that works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is an example where I actually write the schema after dumping out the table as a text file. This is much faster than an InsertCursor at 10.0. Maybe the new da module makes it faster, but it is still a very easy way of defining a schema.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;..... f2 = open("e:/crs/currentgdb/schema.ini","w") f2.write("""[owners.csv] Format=CSVDelimited ColNameHeader=True col1=TTL_TITLE_NO Text Width 20 col2=OWNERS Text Width 120""") f2.close() print "uses schema.ini" arcpy.conversion.TableToTable(csvOwners,ws,"owners")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 07:34:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332988#M25945</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2012-11-08T07:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGis reading field as integer when it should be string.</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332989#M25946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for the suggestions.&amp;nbsp; I ended up using the schema.ini method and that worked fine.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 11:53:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332989#M25946</guid>
      <dc:creator>FrankChin</dc:creator>
      <dc:date>2012-11-08T11:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGis reading field as integer when it should be string.</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332990#M25947</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you Kim Ollivier- I forgot all about that, think that counts as having learned something new today.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;By the way, I used some of your python script samples - for example, not sure off the top of my head where I found it, but used something you wrote to recalc DDP index grid page angles...good show, nice attention to detail!&amp;nbsp; (I pondered over your comment 'careful with up' - I got that after running an experimental strip around 'steep curves' and watched the angle measure 'flop'.&amp;nbsp; Sometimes 'up' is 'down'.)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 12:53:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332990#M25947</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2012-11-08T12:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGis reading field as integer when it should be string.</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332991#M25948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You have not specified how you are reading in the text file.&lt;BR /&gt;&lt;BR /&gt;Have you had a look at the schema.ini specification? This is a Microsoft standard for defining the schema for reading in text files.&lt;BR /&gt;It works really well for loading text files into a geodatabase table because you can rename, set input widths, types to make the simple table to table tool work very well. This avoids a lot of complex coding opening a file and unpicking the components.&lt;BR /&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I ran across this looking for an issue with TabletoTable appearing to not read my csv header row properly. It was forcing only some of the field names in only one of my csv files to be "Field5" and "Field6" ...very weird.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sure enough, I had somehow generated a schema.ini file that was defining it! It was just doing what it was told to do &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for pointing out the existence of this file and how to use it!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Apr 2013 21:28:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332991#M25948</guid>
      <dc:creator>RyanSchuermann</dc:creator>
      <dc:date>2013-04-21T21:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGis reading field as integer when it should be string.</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332992#M25949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Help reference - &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//005s00000010000000"&gt;Desktop Help 10.1: Adding an ASCII or text file table&lt;BR /&gt;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See the section: &lt;/SPAN&gt;&lt;STRONG&gt;Overriding how text files are formatted&lt;/STRONG&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Apr 2013 11:23:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-reading-field-as-integer-when-it-should-be/m-p/332992#M25949</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2013-04-22T11:23:17Z</dc:date>
    </item>
  </channel>
</rss>

