Skip to main content

Hi Guys, no so sure if this questions belongs here:

 

1st> what's the best way to have an internal (to the workbench) datasheet (4 columns x 20 raws of values). Is it in the workspace resources?

 

2nd: I am reading +storing a sequence of characters from a file (a file that I am uploading and processing). I want to compare this sequence (a name) with the aforementioned database in question 1 (actually with one column of the database), So when getting a coincidence name=cell A1 , I will store or been able to retrieve the values of the other cells within the same raw (cell A2, cell A3, and cell A4) .

 

Thank you very much!

 

Jorge

I'd lean towards keeping it in a CSV file external to your workbench, you can then read it in when you need it - I've done similar things like this, you need to make sure its documented that the workbench is dependent on the external CSV.

 

Alternately, and similar to things i've seen others do, is store the data in a PythonCreator and have that create the features you need. Something like the below in a PythonCreator will work. Note you will need to expose the fields you create

import fmeobjects
 
class FeatureCreator(object):
    def __init__(self):
        self.fields = r"f1","f2"]
        self.data= r "v1","v3"],e"v2","v4"]] #store the data row by row
    def input(self,feature):
        for row in self.data: #iterate over each row
            newFeature = fmeobjects.FMEFeature() #create new feature per row
            for value,field in zip(row,self.fields):
                newFeature.setAttribute(field,value) #set field and value for each feature
            self.pyoutput(newFeature) #output feature
    def close(self):
        pass

 


For your first question I've often wondered if we should have a tool to create a table like that. What you can do is put a Creator and AttributeManager down, and in the AttributeManager create an attribute whose value is a csv format table (use the text editor to do that). Then you could use the AttributeSplitter to create a separate feature per row, and again to split the columns into attributes. I think that should work, although I don't have FME at the moment (just installing a new version).

 

For your second question, you could use the FeatureMerger or FeatureJoiner transformers, or - if you prefer using SQL - there is the InlineQuerier transformer.


For your first question I've often wondered if we should have a tool to create a table like that. What you can do is put a Creator and AttributeManager down, and in the AttributeManager create an attribute whose value is a csv format table (use the text editor to do that). Then you could use the AttributeSplitter to create a separate feature per row, and again to split the columns into attributes. I think that should work, although I don't have FME at the moment (just installing a new version).

 

For your second question, you could use the FeatureMerger or FeatureJoiner transformers, or - if you prefer using SQL - there is the InlineQuerier transformer.

"For your first question I've often wondered if we should have a tool to create a table like that. "

I'd really like that

https://community.safe.com/s/idea/0874Q000000TlsNQAS/detail

*I think the screenshot got muddled up in the forum migration


"For your first question I've often wondered if we should have a tool to create a table like that. "

I'd really like that

https://community.safe.com/s/idea/0874Q000000TlsNQAS/detail

*I think the screenshot got muddled up in the forum migration

I hope that gets some more upvotes. I did suggest it to the developers myself - now I think about it, that was probably 10 years ago - but I don't think they quite understood the need.

 

Of course, an alternative would be to create it in the text editor, write it as a file (AttributeFileWriter) and then read back as a CSV, but that still seems quite awkward.


I'd lean towards keeping it in a CSV file external to your workbench, you can then read it in when you need it - I've done similar things like this, you need to make sure its documented that the workbench is dependent on the external CSV.

 

Alternately, and similar to things i've seen others do, is store the data in a PythonCreator and have that create the features you need. Something like the below in a PythonCreator will work. Note you will need to expose the fields you create

import fmeobjects
 
class FeatureCreator(object):
    def __init__(self):
        self.fields = r"f1","f2"]
        self.data= r "v1","v3"],e"v2","v4"]] #store the data row by row
    def input(self,feature):
        for row in self.data: #iterate over each row
            newFeature = fmeobjects.FMEFeature() #create new feature per row
            for value,field in zip(row,self.fields):
                newFeature.setAttribute(field,value) #set field and value for each feature
            self.pyoutput(newFeature) #output feature
    def close(self):
        pass

 

Thanks hkingsbury, Calling a CSV file external to the workbench works. For the FME SERVER, when especially looking to speed up the process,storing the data in PythonCreator might be more handy. However, I miss the capacity to have repository of resources, where I can do a local call to the database. 

 


Reply