<?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: ArcMap can't read string in TXT file in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576595#M45237</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well, I've gone back and re-run the script I wrote using both the example.txt and the example2.txt files as input.&amp;nbsp; Not only are my CSV files correct, but so are my output shapefiles.&amp;nbsp; Below is a screenshot of what I am getting:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]29895[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As you can see in my output, I don't get any NULL or truncated values.&amp;nbsp; I have, however, highlighted the differences that I can see between what I'm getting and what you're getting.&amp;nbsp; First, you have an OBJECTID field and I have an FID field.&amp;nbsp; My guess is that you may have adopted Caleb's code or some modification of it; but I don't think this difference is relevant in the context of the issue you're describing with the output.&amp;nbsp; Nonetheless, it's a difference so I noted it.&amp;nbsp; Secondly, and probably more importantly, the field that seems to be giving you trouble is left justified in my output and right justified in yours.&amp;nbsp; That led me to check the field type; in my output, the field was created as a string.&amp;nbsp; Can you check yours to see if it's getting created as numeric (i.e., Long Integer, Double)?&amp;nbsp; Based on the fact that COUSOU becomes NULL and 88F4 becomes 884 makes me think that the letters aren't recognized as part of the value because the field is not getting created as a string like it should be for you.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, what's different in our environments?&amp;nbsp; Our script is basically the same.&amp;nbsp; our inputs are the same.&amp;nbsp; Yet our results are different.&amp;nbsp; I'm using 10.1 &lt;/SPAN&gt;&lt;STRONG&gt;SP1&lt;/STRONG&gt;&lt;SPAN&gt; build 3143 with Python 2.7... can you check the exact build number of ArcGIS and version number of Python on your machine?&amp;nbsp; For ArcMap, you can use the About ArcMap from the Help menu or run Patchfinder.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT: One last difference in our outputs (yet minor, I think) is that my output is M aware in addition to being Z aware.&amp;nbsp; Yours seems to be only Z aware.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 15 Dec 2013 19:10:40 GMT</pubDate>
    <dc:creator>WilliamCraft</dc:creator>
    <dc:date>2013-12-15T19:10:40Z</dc:date>
    <item>
      <title>ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576579#M45221</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;BR /&gt;&lt;SPAN&gt;I have a bunch of txt files that I need to convert to shapefiles. I first wrote a simple script to format the data as comma delimited. But when I opened the converted files in ArcMap, some of characters didn't show up. For example, "COUSOU" would show up as &amp;lt;NULL&amp;gt;, "88F6" would show as "886". But, in some files, they worked fun. Any one knows why and how to deal with it? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my code for converting file. Any though would help me a lot. Thank you very much! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;inFile = open (arcpy.GetParameterAsText(0),'r') outFile = open (arcpy.GetParameterAsText(1),'w')&amp;nbsp; buffer = []&amp;nbsp; for line in inFile:: &amp;nbsp;&amp;nbsp;&amp;nbsp; line = line.strip() &amp;nbsp;&amp;nbsp;&amp;nbsp; buffer = line.split(' ') &amp;nbsp;&amp;nbsp;&amp;nbsp; buffer = filter (None, buffer) &amp;nbsp;&amp;nbsp;&amp;nbsp; outFile.writelines(",".join(buffer)) &amp;nbsp;&amp;nbsp;&amp;nbsp; outFile.writelines("".join('\n'))&amp;nbsp; inFile.close() outFile.close()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Dec 2013 19:43:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576579#M45221</guid>
      <dc:creator>YichiLiu1</dc:creator>
      <dc:date>2013-12-13T19:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576580#M45222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm happy to try and help you, but I'll need a bit more info from you first.&amp;nbsp; Please post the input file or at least a few sample lines of what the file contents look like.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Dec 2013 23:07:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576580#M45222</guid>
      <dc:creator>WilliamCraft</dc:creator>
      <dc:date>2013-12-13T23:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576581#M45223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'm happy to try and help you, but I'll need a bit more info from you first.&amp;nbsp; Please post the input file or at least a few sample lines of what the file contents look like.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you so much! I've attached two text files as examples. I can open test2.txt, however, when I opened test2.txt, "COUSOU" became &amp;lt;NULL&amp;gt; and "88F6" became "886".&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Dec 2013 00:53:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576581#M45223</guid>
      <dc:creator>YichiLiu1</dc:creator>
      <dc:date>2013-12-14T00:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576582#M45224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is test2.txt&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Dec 2013 01:00:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576582#M45224</guid>
      <dc:creator>YichiLiu1</dc:creator>
      <dc:date>2013-12-14T01:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576583#M45225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I first wrote a simple script to format the data as comma delimited. &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Just curious, is the file you provided the modified one from the script or is it the original?&amp;nbsp; Please provide the original if possible.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Which version of ArcGIS are you working with?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Dec 2013 01:02:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576583#M45225</guid>
      <dc:creator>WilliamCraft</dc:creator>
      <dc:date>2013-12-14T01:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576584#M45226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Just curious, is the file you provided the modified one from the script or is it the original?&amp;nbsp; Please provide the original if possible.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;Which version of ArcGIS are you working with?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried both 10.0 and 10.1. I only have modified data with me right now. I just tried same data on my own computer (I was using computers at work), all of them worked completely fine! I am totally confused. Is is because of the computer settings?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Dec 2013 01:45:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576584#M45226</guid>
      <dc:creator>YichiLiu1</dc:creator>
      <dc:date>2013-12-14T01:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576585#M45227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am not sure of your computer settings, but if you would like me to help with the code please provide an example of the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;original &lt;/SPAN&gt;&lt;SPAN&gt;source file.&amp;nbsp; You said that you were altering the TXT files to become comma-delimited, so whatever you are running the script against is what I would need to start with.&amp;nbsp; It sounds like the script you wrote isn't quite right as it is truncating certain values or you are getting NULL returns on others.&amp;nbsp; It's possible that we could write some alternate Python that would convert your source file(s) directly to Shapefile format without having to produce an intermediate comma-separated file.&amp;nbsp; Without that, I can't troubleshoot your output file.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Dec 2013 01:50:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576585#M45227</guid>
      <dc:creator>WilliamCraft</dc:creator>
      <dc:date>2013-12-14T01:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576586#M45228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Alternatively, if you are satisfied with the output from your script then you can use the Add XY Data option in ArcMap to create an XY event layer using the X and Y fields.&amp;nbsp; The rest of the info in your file becomes attribution.&amp;nbsp; Then, right click the layer in ArcMap's table of contents and use the option for Export Data.&amp;nbsp; Pick Shapefile format per your requirements and save the output to a familiar location.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Dec 2013 01:59:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576586#M45228</guid>
      <dc:creator>WilliamCraft</dc:creator>
      <dc:date>2013-12-14T01:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576587#M45229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I am not sure of your computer settings, but if you would like me to help with the code please provide an example of the &lt;SPAN style="font-style:italic;"&gt;original &lt;/SPAN&gt;source file.&amp;nbsp; You said that you were altering the TXT files to become comma-delimited, so whatever you are running the script against is what I would need to start with.&amp;nbsp; It sounds like the script you wrote isn't quite right as it is truncating certain values or you are getting NULL returns on others.&amp;nbsp; It's possible that we could write some alternate Python that would convert your source file(s) directly to Shapefile format without having to produce an intermediate comma-separated file.&amp;nbsp; Without that, I can't troubleshoot your output file.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very much! I tried couple times again and figured out that the version of ArcGIS did make a difference. TXT files showed up correctly if I use 10.1. Now, I'm facing a new problem. Some data, for example, "59E13" was read as double instead of string, which exported as 5.900000e+14. Do you know how can I deal with this issue? I would really like to learn how to convert from source files directly to Shapefiles if it will make everything easier. I attached a sample txt file here. I need to extract data from the table at the bottom and convert is to shapefile or feature class. Right now I am using the approach you mentioned, make XY event layer and then export. Again, thank you very much for your help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Dec 2013 18:40:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576587#M45229</guid>
      <dc:creator>YichiLiu1</dc:creator>
      <dc:date>2013-12-14T18:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576588#M45230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Great, thanks for providing the file.&amp;nbsp; Give me a short bit of time and I'll reply with a 10.1 solution for you.&amp;nbsp; I'm going to assume that all of your source files follow this format, too.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Dec 2013 21:44:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576588#M45230</guid>
      <dc:creator>WilliamCraft</dc:creator>
      <dc:date>2013-12-14T21:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576589#M45231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, give this a try in a 10.1 environment.&amp;nbsp; You can run it through Python IDLE or you can double click it to run it through the Windows Command Prompt.&amp;nbsp; Either way, there will be two user inputs it asks for: the first is the full path and file name for the input TXT file; the second is the full path to the directory at which the output files should be written.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]29889[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once the script completes, you will see that I decided to actually retain a CSV in addition to the Shapefile you asked for.&amp;nbsp; I did this for a bit of QA so you can make sure what got parsed from the input file matches the Shapefile.&amp;nbsp; Now, here's the thing... your input source files must all be in the same format in terms of field name sequencing.&amp;nbsp; If they differ, then your field names in the Shapefile may not match what the values really represent in the input file.&amp;nbsp; Also, I've not set a spatial reference on your data for the Add XY Event Layer GP tool in the script.&amp;nbsp; You may need to do that for overlay accuracy purposes.&amp;nbsp; Lastly, you're welcome to modify this to create FGDB feature classes rather than Shapefiles.&amp;nbsp; Using a Shapefile means that your field names are limited in character length, so they may look a bit funny.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know what you think!&amp;nbsp; The only thing I'll ask for is, if you are happy with the script and my efforts, please mark this as the correct answer for the thread and then vote up other helpful responses in the thread as well.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Dec 2013 00:03:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576589#M45231</guid>
      <dc:creator>WilliamCraft</dc:creator>
      <dc:date>2013-12-15T00:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576590#M45232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;William had some very good points in his feedback. As he suggested, you will want to add a spatial reference for your output files and with the lengthy field names, gdb feature classes are the way to go (shapefiles have a 10 character limit).&amp;nbsp; Here is my attempt at it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os, time, glob
arcpy.env.overwriteOutput = True

arcpy.env.workspace = ws = arcpy.GetParameterAsText(0)
SR = arcpy.GetParameterAsText(1)
gdb = str(arcpy.CreateFileGDB_management(ws, 'VegetationAnalysis.gdb').getOutput(0))
csv_fold = os.path.join(ws, 'CSV')
if not os.path.exists(csv_fold):
&amp;nbsp;&amp;nbsp;&amp;nbsp; os.makedirs(csv_fold)

for txt in glob.glob(os.path.join(ws, '*.txt')):
&amp;nbsp;&amp;nbsp;&amp;nbsp; with open(txt) as rd:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lines = [line for line in rd.readlines() if ' NG' in line]
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Creating CSV file for %s...."&amp;nbsp; %os.path.basename(txt))
&amp;nbsp;&amp;nbsp;&amp;nbsp; outFile = os.path.join(csv_fold, os.path.basename(txt.replace('.txt','.csv')))
&amp;nbsp;&amp;nbsp;&amp;nbsp; with open(outFile, 'w') as csv:&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; csv.write("X,Y,Z,Station,AboveGround,AboveGroundOK,BackWeatherStrCase1,BackWeatherStrCase2,VertorRadialMargin,HorzMargin,MinDistToWireGrow,OK,RadialMargin,MinDistToWireFall,DistToWire,OK\n")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; csv.write('\n'.join(",".join(line.strip().split()) for line in lines))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Generating Feature Class...")

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeXYEventLayer_management(outFile,'X','Y','XY_event_layer',SR,'Z')
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management('XY_event_layer',os.path.join(gdb, 'SurveyPoints_%s' %os.path.basename(txt.split('.')[0])))
arcpy.AddMessage("Complete.&amp;nbsp; Files located at " + gdb)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also a few notes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. built in keywords should not be used for variable names (i.e. buffer) even though it doesn't hurt anything in this situation&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. the filter() function was not necessary since we were already splitting by spaces and stripping out any whitespace (shouldn't be any None data types after that)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have attached a 10.0 toolbox.&amp;nbsp; Mine is designed to supply a folder that contains all the text files and it will iterate through all those and create a csv and feature class for each txt file.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, if you end up using my code, you should still mark &lt;/SPAN&gt;&lt;STRONG&gt;William's answer&lt;/STRONG&gt;&lt;SPAN&gt; as the answer and not mine as he has done a lot of work on this and I just borrowed some of his code.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:49:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576590#M45232</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T00:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576591#M45233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your help! However, both methods didn't seem to solve my problem. The result is still not right. The image below showed what I got, 'COUSOU' became &amp;lt;NULL&amp;gt; and '88F4' became '884'. Do your guys have any idea why did that happen?[ATTACH=CONFIG]29892[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am actually thinking about using cursor to create a shapefile/feature class directly. But some of the files might have over 3 millions or 4 millions data entries. I don't know if the cursor will be able to handle that. Any one knows?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Dec 2013 14:34:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576591#M45233</guid>
      <dc:creator>YichiLiu1</dc:creator>
      <dc:date>2013-12-15T14:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576592#M45234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;For whatever reason, the field containing the altered values looks like may be getting created as numeric.&amp;nbsp; I'll take another look at my output to see if I'm seeing similar behavior in the data type for the field, but when I checked the results from converting the example.txt you provided all of the values were outputted correctly.&amp;nbsp; That is, I didn't see any NULL of truncated values as you're seeing.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Dec 2013 14:39:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576592#M45234</guid>
      <dc:creator>WilliamCraft</dc:creator>
      <dc:date>2013-12-15T14:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576593#M45235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I used this file to test.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Dec 2013 15:07:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576593#M45235</guid>
      <dc:creator>YichiLiu1</dc:creator>
      <dc:date>2013-12-15T15:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576594#M45236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The cvs file is outputted correctly. It's the conversion from cvs to shapefile.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Dec 2013 15:08:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576594#M45236</guid>
      <dc:creator>YichiLiu1</dc:creator>
      <dc:date>2013-12-15T15:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576595#M45237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well, I've gone back and re-run the script I wrote using both the example.txt and the example2.txt files as input.&amp;nbsp; Not only are my CSV files correct, but so are my output shapefiles.&amp;nbsp; Below is a screenshot of what I am getting:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]29895[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As you can see in my output, I don't get any NULL or truncated values.&amp;nbsp; I have, however, highlighted the differences that I can see between what I'm getting and what you're getting.&amp;nbsp; First, you have an OBJECTID field and I have an FID field.&amp;nbsp; My guess is that you may have adopted Caleb's code or some modification of it; but I don't think this difference is relevant in the context of the issue you're describing with the output.&amp;nbsp; Nonetheless, it's a difference so I noted it.&amp;nbsp; Secondly, and probably more importantly, the field that seems to be giving you trouble is left justified in my output and right justified in yours.&amp;nbsp; That led me to check the field type; in my output, the field was created as a string.&amp;nbsp; Can you check yours to see if it's getting created as numeric (i.e., Long Integer, Double)?&amp;nbsp; Based on the fact that COUSOU becomes NULL and 88F4 becomes 884 makes me think that the letters aren't recognized as part of the value because the field is not getting created as a string like it should be for you.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, what's different in our environments?&amp;nbsp; Our script is basically the same.&amp;nbsp; our inputs are the same.&amp;nbsp; Yet our results are different.&amp;nbsp; I'm using 10.1 &lt;/SPAN&gt;&lt;STRONG&gt;SP1&lt;/STRONG&gt;&lt;SPAN&gt; build 3143 with Python 2.7... can you check the exact build number of ArcGIS and version number of Python on your machine?&amp;nbsp; For ArcMap, you can use the About ArcMap from the Help menu or run Patchfinder.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT: One last difference in our outputs (yet minor, I think) is that my output is M aware in addition to being Z aware.&amp;nbsp; Yours seems to be only Z aware.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Dec 2013 19:10:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576595#M45237</guid>
      <dc:creator>WilliamCraft</dc:creator>
      <dc:date>2013-12-15T19:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576596#M45238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think the version of ArcGIS made the difference. I was using ArcGIS 10.0 and if I ran same file in ArcGIS 10.1, it didn't seem to have that problem. My field type came out as double in 10.0. I checked and figured out that only strings with 'F' in them have this problem. I can run the data in computers with ArcGIS 10.1 for now. However, I still want to know why 10.0 does this. Just curious!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And again, thank you very much for your help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Dec 2013 03:28:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576596#M45238</guid>
      <dc:creator>YichiLiu1</dc:creator>
      <dc:date>2013-12-16T03:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: ArcMap can't read string in TXT file</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576597#M45239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; I think the version of ArcGIS made the difference. I was using ArcGIS 10.0 and if I ran same file in ArcGIS 10.1, it didn't seem to have that problem. My field type came out as double in 10.0. I checked and figured out that only strings with 'F' in them have this problem. I can run the data in computers with ArcGIS 10.1 for now. However, I still want to know why 10.0 does this. Just curious!&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;And again, thank you very much for your help!&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Apologize for the delayed response, but if you're still waiting for an answer as to this ArcGIS 10.0 behavior and the workaround, I can fill you in...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The source csv text files (part of the output of the script) were written to correctly - the error occurred in how ArcGIS read that 'intermediate' csv output to create the final gdb fc output. A simple entry in an ini file can 'override' registry settings that ArcGIS may use in reading these files. On my 10.0 machine, I duplicated your error, then modified the companion ini file (that resides in the same dir), reran the MakeXYEvent and CopyFeature tool processes and that corrected the error...this was the ini entry for the test file I ran (example.csv):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
[example.csv]
Format=CSVDelimited
ColNameHeader=True
MaxScanRows=1
Col7=BackWeatherStrCase1 Char
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note the 'Col7=BackWeatherStrCase1 Char' line -- this means read that field (corresponding to column 7) as character. A field width number is optional after 'Char'. Of course, it would be wise to add the formatting specs to the ini for the other fields, but for this test I was only interested in overriding this behavior:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
IDLE 2.6.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ==== No Subprocess ====
&amp;gt;&amp;gt;&amp;gt; outFile = r'C:\mapdocs\temp\textINI\CSV\example.csv'

&amp;gt;&amp;gt;&amp;gt; arcpy.MakeXYEventLayer_management(outFile,'X','Y','XY_event_layer')
&amp;lt;Result 'XY_event_layer'&amp;gt;

&amp;gt;&amp;gt;&amp;gt; arcpy.CopyFeatures_management('XY_event_layer', r'C:\mapdocs\temp\textINI\VegetationAnalysis.gdb\test1')
&amp;lt;Result 'C:\\mapdocs\\temp\\textINI\\VegetationAnalysis.gdb\\test1'&amp;gt;

&amp;gt;&amp;gt;&amp;gt; &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;# Let's test read the file gdb results:&lt;/SPAN&gt;
&amp;gt;&amp;gt;&amp;gt; rows = arcpy.SearchCursor(r'C:\mapdocs\temp\textINI\VegetationAnalysis.gdb\test1')

&amp;gt;&amp;gt;&amp;gt; &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;# ...get the 1st record&lt;/SPAN&gt;
&amp;gt;&amp;gt;&amp;gt; row = rows.next()

&amp;gt;&amp;gt;&amp;gt; &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;# ...get a field list to call by name with getValue:&lt;/SPAN&gt;
&amp;gt;&amp;gt;&amp;gt; fields = arcpy.ListFields(r'C:\mapdocs\temp\textINI\VegetationAnalysis.gdb\test1')

&amp;gt;&amp;gt;&amp;gt; &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;# For the 1st row, print the field values read via the cursor:&lt;/SPAN&gt;
&amp;gt;&amp;gt;&amp;gt; for field in fields:
&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; print 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;&amp;nbsp;&amp;nbsp; 
OBJECTID ... 1
Shape ... &amp;lt;geoprocessing describe geometry object object at 0x096D9050&amp;gt;
X ... 751274.78
Y ... 1484273.55
Z ... 20.82
Station ... 270.52
AboveGround ... 16.97
AboveGroundOK ... OK
BackWeatherStrCase1 ... None&amp;nbsp; &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;# ah, this is the Null value, of course incorrect&lt;/SPAN&gt;
BackWeatherStrCase2 ... WCD-0in-0psf-100degC-WCD
VertorRadialMargin ... -0.01
HorzMargin ... 0.0
MinDistToWireGrow ... 9.99
OK ... NG
RadialMargin ... 0.0
MinDistToWireFall ... 0.0
DistToWire ... 9.99
OK_1 ...
&amp;gt;&amp;gt;&amp;gt;&amp;nbsp; 

&amp;gt;&amp;gt;&amp;gt; row.Station
270.51999999999998

&amp;gt;&amp;gt;&amp;gt; &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;# what is the BackWeatherStrCase1 88F4 value read as?&lt;/SPAN&gt;
&amp;gt;&amp;gt;&amp;gt; while row:
&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 row.Station &amp;gt; 300.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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print row.BackWeatherStrCase1
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break
&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; row = rows.next()
 
&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; 
884.0&amp;nbsp; &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;# clearly wrong!&lt;/SPAN&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;nbsp; 
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then, after the ini file 'fix', the result (for this file result, this field only) tests out okay:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; print outFile
C:\mapdocs\temp\textINI\CSV\example.csv

&amp;gt;&amp;gt;&amp;gt; arcpy.MakeXYEventLayer_management(outFile,'X','Y','XY_event_layer')
&amp;lt;Result 'XY_event_layer'&amp;gt;

&amp;gt;&amp;gt;&amp;gt; arcpy.CopyFeatures_management('XY_event_layer', r'C:\mapdocs\temp\textINI\VegetationAnalysis.gdb\test1')
&amp;lt;Result 'C:\\mapdocs\\temp\\textINI\\VegetationAnalysis.gdb\\test1'&amp;gt;

&amp;gt;&amp;gt;&amp;gt; rows = arcpy.SearchCursor(r'C:\mapdocs\temp\textINI\VegetationAnalysis.gdb\test1')

&amp;gt;&amp;gt;&amp;gt; &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;# this time, just printing all the vals in the BackWeatherStrCase1 field:&lt;/SPAN&gt;
&amp;gt;&amp;gt;&amp;gt; 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;&amp;nbsp;&amp;nbsp;&amp;nbsp; print row.BackWeatherStrCase1
 
&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; 
COUSOU
COUSOU
COUSOU
COUSOU
COUSOU
88F4
88F4
88F4
88F6
88F10
88F10
88F10
88F10
88F10
88F15
88F15
88F15
88F15
88F15
88F15
88F15
88F15
88F15
88F15
88F15
88F16
88F16
88F16
&amp;gt;&amp;gt;&amp;gt;&amp;nbsp; &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;# read error corrected.&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The info contained here was vital:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ms709353(VS.85).aspx" rel="nofollow noopener noreferrer" target="_blank"&gt;http://msdn.microsoft.com/en-us/library/ms709353(VS.85).aspx&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There was a hint about schema.ini file usage here in this doc excerpt at the Make XY Event Layer web help:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"The standard delimiter for tabular text files with extensions .csv or .txt is a comma, and for files with a .tab extension, a tab. To use an input table with a nonstandard delimiter, you must first specify the correct delimiter used in the table using a schema.ini file."&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000006z000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000006z000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...again here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"ArcGIS uses the Microsoft OLE DB provider for Open Database Communication (ODBC) drivers and the Microsoft ODBC Text Driver for text files to access tabular data in text files. The driver stores data description (schema) information about each text file in a file named schema.ini so the data can be accessed properly. This file refers only to the text data files in the directory in which it resides."&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//005s00000010000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//005s00000010000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:49:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-can-t-read-string-in-txt-file/m-p/576597#M45239</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-12T00:49:06Z</dc:date>
    </item>
  </channel>
</rss>

