I have 1000 files from which I need to copy the first record and insert into a new feature class. Additionally, is there a way to do this without copying the Field headers as well?

The end result should be a single file (I'm thinking a feature class which I would then convert to Excel) with 1000 records; every record would represent the first record of my original feature classes.

Is there any way I can automate this?

I am working on ArcMap 10.5.

enter image description here

closed as off-topic by PolyGeo May 9 at 10:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    I would use ArcPy Search and Insert cursors but a non-coding way with ModelBuilder would be to use the Select and Append tools. – PolyGeo May 8 at 21:51
  • What would be the SQL expression to select the first record of each feature class in the Append tool? – Sevi May 8 at 22:21
  • You use it in the Select tool and it is feature ID = 1 (maybe 0 in some formats). – PolyGeo May 8 at 22:27
  • 1
    "Is it possible" questions are almost always answered "Yes." Please choose among the three approaches detailed in the comments here, and Edit your question to focus on how to further your attempt at that solution. – Vince May 9 at 1:46

You can use arcpy. List all feature classes, Select first record in each and output as new feature class then merge all:

import arcpy, os

input_database = r'C:\Inputdata.gdb' #Best if only the 1000 feature classes in here, or use wildcards in listfeatureclasses
output_database = r'C:\Outputdata.gdb' #Empty output db

arcpy.env.workspace = input_database
fclist = arcpy.ListFeatureClasses() #Wildcard is possible to limit what is listed

#Select first record and save in output db
for fc in fclist:
    first_oid = [i[0] for i in arcpy.da.SearchCursor(fc,'OID@')][0]
    sql = "{0}={1}".format(arcpy.AddFieldDelimiters(fc, arcpy.Describe(fc).OIDFieldName), first_oid)
    arcpy.Select_analysis(in_features=fc, out_feature_class=os.path.join(output_database, fc), 

#Merge all
arcpy.env.workspace = output_database
fclist = arcpy.ListFeatureClasses()
arcpy.Merge_management(inputs=fclist, output='megamerge')

If your fields do not match output will have all fields from all fcs.

But if you are only interested to get the data into excel you dont need to select and merge, instead use pandas module:

import pandas as pd
import arcpy

input_database = r'C:\Inputdata.gdb'
arcpy.env.workspace = input_database
fclist = arcpy.ListFeatureClasses()

for count, fc in enumerate(fclist):
    fieldlist = [f.name for f in arcpy.ListFields(fc) if f.type not in ['OID','Geometry']]
    firstrecord = next(arcpy.da.SearchCursor(fc, fieldlist))
    if count==0:
        df = pd.DataFrame(data=[firstrecord], columns=fieldlist)
        tempdf = pd.DataFrame(data=[firstrecord], columns=fieldlist)
        df = pd.concat([df, tempdf], sort=False)

#df.to_excel() #This often does not work when i try, i use to_clipboard then paste to excel instead

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