All readers today is for only one extension in a time. Sometime you have to upload multiple files in a flow. It would be nice to be able to add a zip with multiple files. And then the path for each files to use in a reader at your choice.
This pythonscript read all files in a zip and returns the path. You need a attribute exposer to get the attributes.
import zipfile
import os
import fmeobjects
class FeatureProcessor(object):
def __init__(self):
pass
def input(self, feature):
zip_path = r'yourzipfile.zip'
extract_to = os.path.dirname(zip_path)
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(extract_to)
for file in zip_ref.namelist():
f = fmeobjects.FMEFeature()
f.setAttribute('file_name', file)
f.setAttribute('file_path', os.path.join(extract_to, file))
self.pyoutput(f)
def close(self):
pass