How to create a shp with specific attributes from txt file

4403
14
Jump to solution
05-31-2015 11:37 AM
KONPETROV
Occasional Contributor III

Hi, i have the following code:

import arcgisscripting
gp = arcgisscripting.create()
input = "c:/Borders/home.txt"
inSep = "."
output = "c:/Borders/outtext.txt"
gp.CreateFeaturesFromTextFile(input, inSep, output, "#")

And my point txt is in that form:

Point

0 8674596.8 9856351.9 100.967430980

End

But the point i am getting doesn't have the third column. Why is that happening?

0 Kudos
14 Replies
KONPETROV
Occasional Contributor III

I  could do that also Ms Fox, but i don't know what the first line of my txt should be, also the last column is not z or m value but a value i just need for each point

0 Kudos
SepheFox
Frequent Contributor

Hi Kon, The first line of your text would just be the field headings (x, y, value). A z or m value is not required. The tool converts your xy values to points, and maintains the other value fields as required. I just did a quick test of made up data of 3 points. It worked great. This was a simple notepad file with tabs between values:

KONPETROV
Occasional Contributor III

Ms Fox just to try it, i brought my data to that form

x,y,value
674596.8 9856351.9 100.967430980

and although the text in ArcMap has correctly put each number in x,y,value column when it comes to make x,y event layer i get an 000212 error. I tried the same with comma(,) and a space also but was the same.

0 Kudos
OwenEarley
Occasional Contributor III

Make sure that the delimiters are the same for your column headings and values, for example use commas:

x,y,value  
674596.8,9856351.9,100.967430980

SepheFox
Frequent Contributor

Well, I can see in your code snippet, you used comma separators for the first line, and then space or tab for the subsequent line. They would need to be the same. As I said, I used tab with no difficulties at all. The error description states:

"Verify that you have entered the correct parameters for this operation and that the data contained in the X and Y fields is in the correct format. The fields must be numeric to be displayed. For example, if the coordinate value is stored in degrees/minutes/seconds in a field (for example, -120 13 58), you need to convert the values to decimal degrees and store them in a numeric field. In addition, some characters in field names are not supported, such as dashes (for example, x-coord for the field name), spaces, and brackets. Before adding x,y data, you should edit the field names to remove these characters. For example, you can use the underscore character instead of the dash character in field names. For more information, see the Make XY Event Layer tool help." so you should make sure you don't have any of these issues first.