Skip to main content

I'm looking to do something that I'm not sure is totally possible, but I'm trying. My goal is to copy a seed MDB file for each unique input attribute value, and rename to that value. I could have upwards of 200 unique names, and there will be one feature enter the PythonCaller per unique attribute. This is where my lackluster Python skills have taken me. The exception I'm getting is 'global name library is not defined'.

I have a feeling that even if this did process through as it is, I would only get one mdb copy with the first feature to pass through.

Is there a reason for using python over the file copy writer?


Is there a reason for using python over the file copy writer?

Wow, I was really overthinking this. I had never used the FileCopyWriter before now. Thanks!

I completely agree with @egomm, but nevertheless, here's a suggestion for a PythonCaller just in case:

import fmeobjects
import shutil

def processFeature(feature):
    library = feature.getAttribute('library_name')
    shutil.copyfile('e:\\seed.mdb', 'e:\\project\\%s.mdb' % library)

If you have duplicate values for library_name entering the PythonCaller, you could prefix it with a DuplicateFilter to only retain the unique values.


Reply