0

So here is a script that is used to extract a specific file from multiple folders and subfolders. It run smooth, until the end.

import os, fnmatch, arcpy

arcpy.env.workspace = r'C:\Users\sysadmin\Desktop\DataMagement\Comp_3\SA_MGCP3.gdb'

fcMerged = 'MergedFeatureClass'
fcClipped = 'Extraction_Mine'
fcToClip = r'C:\Users\sysadmin\Desktop\DataMagement\SA.shp

filesMatched = list()

for root, subfolders, files in os.walk (r'C:\Users\sysadmin\Desktop\DataMagement\MGCP_Raw'):

    for f in fnmatch.filer(files, 'AAA010.shp'):

        filesMatched.append(os.path.join(root,f))

Here is the error

    arcpy.Merge_managment(filesMatched, fcMerged)

    arcpy.Clip_analysis(fcMerged, fcToClip, Extraction_Mine)

The error code reads:

Traceback (most recent call last)' File "C:\User\sysadmin\Desktop\test.py", line 17 in < module 7 > arcpy.Merge_management (filesMatched, fcMerged) Attribute error: 'Module' object has no attribute 'Merge_Management'

2

You have a typo:

arcpy.Merge_managment

should be:

arcpy.Merge_management
  • Also, the correct way to construct a list is:filesMatched = []. If you want to construct a tuple, it would be filesMatched = (). – RHB Mar 2 '16 at 19:08
  • And another typo. The correct syntax is fnmatch.filter(names, pattern). And I would imagine the pattern will need to contain wildcard characters, unless you only want it to match one file. Also, the fnmatch module is designed for Unix, and it looks like you are on a Windows machine. – RHB Mar 2 '16 at 19:16
  • Typo in Management capitalised – FelixIP Mar 2 '16 at 20:05

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