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.


3 Answers 3


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.


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)
  • This is the answer that worked for me. This should be the accepted answer.
    – Blairg23
    Commented Jun 21, 2016 at 19:02

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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