Append a list of shapes to a feature class

613
1
11-23-2018 06:20 AM
FlavioFelix
New Contributor III

I recieve every month a folder with many shapes.

I have to export one by to a file geodatabase. 

I'm trying to create a script that append the list of shapes in a folder to a file geodatabase and I don't find a solution.

I'm new in python so looking for solutions trying this.

import arcpy

out=r'F:\CAR_Geral.gdb'
shapes=r'F:\INSCRITO_CAR'


for i in shapes:
arcpy.FeatureClassToGeodatabase_conversion(shapes,out)

0 Kudos
1 Reply
JoshuaBixby
MVP Esteemed Contributor

For future reference, ArcPy questions usually get posted in Python‌.  This place is for ArcGIS API for Python questions.

Adapting the Code sample from Feature Class To Geodatabase—Conversion toolbox | ArcGIS Desktop:

Code sample

FeatureClassToGeodatabase example (Python window)

The following Python window script demonstrates how to use the FeatureClassToGeodatabase function in immediate mode.

import arcpy arcpy.env.workspace = 'C:/data'
arcpy.FeatureClassToGeodatabase_conversion(['climate.shp', 'majorrds.shp'],
                                            'C:/output/output.gdb')

Try the following:

import arcpy

gdb = r'F:\CAR_Geral.gdb'
ws = r'F:\INSCRITO_CAR'

arcpy.env.workspace = ws
arcpy.FeatureClassToGeodatabase_conversion(
    arcpy.ListFeatureClasses('*.shp'),
    gdb
)‍‍‍‍‍‍‍‍‍‍