I am trying to merge a number of shapefiles with the following code:
import arcpy, os, datetime
#Set working directory
cd = r"C:\Users\..."
arcpy.env.workspace = cd
os.chdir(cd)
arcpy.env.overwriteOutput = True
directory = cd + "/shapefiles"
shapefiles = []
for root, dirs, files in os.walk(directory):
files = [ fi for fi in files if fi.endswith(".shp") ]
for filename in files:
shapefile = (os.path.join(directory, filename))
shapefiles.append (shapefile)
arcpy.Merge_management(shapefiles, cd + "all_districts.shp")
This fails due to Error 001156
which arises because some fields in some shapefiles exceed the maximum text length. According to this question, it is not possible to increase the maximum text length and the answers suggest that one should merge the shapefiles within a geodatabase.
I am new to geodatabases, so I do not know how to do this. How can I merge all shapefiles from my folder into a geodatabase?