AnsweredAssumed Answered

Load data (shp and features) out of multiple folders and subfolders in one FGDB

Question asked by JB1234510 on Aug 8, 2016
Latest reply on Aug 8, 2016 by jskinner-esristaff
## Load Data

import arcpy
import os

workspace = r"R:\Daten\geo_daten_Kopie"
out_workspace = r"R:\Karto\Bierer2016\OrdnerRDatenGeodatenBereinigen\SIC_Geodaten.gdb\data"

import arcpy
import os

feature_classes = []
for dirpath, dirnames, filenames in arcpy.da.Walk(workspace, datatype="FeatureClass"): ##, type="Polygon"):
    for filename in filenames:
        feature_classes.append(os.path.join(dirpath, filename))
        name = os.path.join(dirpath, filename)
        print name
        BaseName = os.path.basename(name)
        print BaseName
        BaseNameCopy = BaseName.split(".shp")
        print BaseNameCopy
        arcpy.CopyFeatures_management(filename, os.path.join(out_workspace, BaseNameCopy))

The code leads to this error message:


Traceback (most recent call last):

  File "H:/python_scripte/ListFolderandShapes/", line 22, in <module>

    arcpy.CopyFeatures_management(filename, os.path.join(out_workspace, BaseNameCopy))

  File "C:\Python27\ArcGIS10.2\lib\", line 73, in join

    elif isabs(b):

  File "C:\Python27\ArcGIS10.2\lib\", line 58, in isabs

    return s != '' and s[:1] in '/\\'

TypeError: 'in <string>' requires string as left operand, not list


Anyone has got an idea for a better solution?