Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some txt files that are basically attribute tables (object ID, latitude, longitude, area). In ArcMaps, I have been converting these files into feature classes and saving them in a geodatabase using the following steps:

  • Right click file

    Create Feature Class > From XY Table

    Click on the Coordinate System of Input Coordinates button and then select coordinate system

    Save as File and Personal Geodatabase feature classes and output to selected geodatabase

Since I have a large number of files, I'd like to script this using Python. I don't have a problem iterating throuygh the file folder and getting a list of all files, but which function from the ARC Python library should I use? The is Create Feature Class tool the best one I've been able to find so far, but it created an empty feature class.

i have tried opening the Geoprocessing > results tab while creating the feature class manually, so that I can copy as script, but for these actions I am not seeing any entries in the result pane.

share|improve this question
I think what you're looking for is in… The tool you have linked to just creates an empty feature class - it doesn't write anything to it. – Chris W Jun 13 '14 at 19:31
up vote 6 down vote accepted

You make no mention that you have any problems reading your text file, so I am assuming that it is just how to get the coordinates into a feature class that has you stumped.

There are a number of ways to do this so some suggestions to start looking at are:

Both have code examples that I think should get you past where you are stuck. I recommend getting the code samples to work first and then try to apply to your situation second.

share|improve this answer

You are going to want to use the make XY event layer and then save the output to file.

share|improve this answer

R0B0Donuts answer is not far off getting your job done. BUT you have to alter that last step from the example (XYeventLayer example.). You do not want to save the XYeventlayer to an layerfile but you do a FeatureClassToFeatureClass conversion (FC to FC conversion). That actually saves the XYeventLayer to a featurelayer.

arcpy.MakeXYEventLayer_management(in_csv_Table, x_coords, y_coords, XY_Layer, spRef, z_coords)
arcpy.FeatureClassToFeatureClass_conversion(XY_layer, outLocation, outFeatureClass, expression)
share|improve this answer
This is the answer that worked for me. This should be the accepted answer. – Blairg23 Jun 21 at 19:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.