Question

How to use the datasets in the workspace in a "PythonCreator" transformer?

  • 27 August 2018
  • 8 replies
  • 0 views

Hi,

I have 2 datasets in my workspace and I want to use "PythonCreator" transformer to create a new feature base on those datasets in my workspace but I don't know how to use workspace datasets in "PythonCreator" transformer. Could you help me?


8 replies

Userlevel 2
Badge +17

Hi @nafise, if FME supports the data format, you could use the FMEUniversalReader class from FME Objects Python API to implement to read features from a dataset.

In personal opinion, however, generally there is no advantage to do so, since using the API class is equivalent to use a regular FME reader. Further, using a regular reader (or the FeatureReader transformer) would be much easier and also much more robust.

Why do you need to use the PythonCreator to read features from the datasets?

Hi @nafise, if FME supports the data format, you could use the FMEUniversalReader class from FME Objects Python API to implement to read features from a dataset.

In personal opinion, however, generally there is no advantage to do so, since using the API class is equivalent to use a regular FME reader. Further, using a regular reader (or the FeatureReader transformer) would be much easier and also much more robust.

Why do you need to use the PythonCreator to read features from the datasets?

Hi @takashi

 

Thank you for your answer. I already have 2 readers in my workspace and each one has a feature type. I want to create a new feature and use the data of those feature types for the new feature. I don't know how to access to the those feature types data via python code in "PythonCreator" transformer?

 

 

 

Userlevel 2
Badge +17

Hi @nafise, if FME supports the data format, you could use the FMEUniversalReader class from FME Objects Python API to implement to read features from a dataset.

In personal opinion, however, generally there is no advantage to do so, since using the API class is equivalent to use a regular FME reader. Further, using a regular reader (or the FeatureReader transformer) would be much easier and also much more robust.

Why do you need to use the PythonCreator to read features from the datasets?

What are the specific contents of "the data of those feature types" which should be used to create a new feature?

 

 

Userlevel 2
Badge +17

Hi @nafise, if FME supports the data format, you could use the FMEUniversalReader class from FME Objects Python API to implement to read features from a dataset.

In personal opinion, however, generally there is no advantage to do so, since using the API class is equivalent to use a regular FME reader. Further, using a regular reader (or the FeatureReader transformer) would be much easier and also much more robust.

Why do you need to use the PythonCreator to read features from the datasets?

Looks like the FeatureMerger is the way to go.

 

What are the criteria merge the data from a "cable_BOM" feature to a "cable" feature?

 

Hi @nafise, if FME supports the data format, you could use the FMEUniversalReader class from FME Objects Python API to implement to read features from a dataset.

In personal opinion, however, generally there is no advantage to do so, since using the API class is equivalent to use a regular FME reader. Further, using a regular reader (or the FeatureReader transformer) would be much easier and also much more robust.

Why do you need to use the PythonCreator to read features from the datasets?

I couldn't use "FeatureMerger" because for every row of "cable_BOM" the merge condition can be changed and the connection between "cable" and "cable_BOM" is 1 to n.

 

In general my question is how “PythonCreator” transformer can get access to the feature type information in the readers that be added in a workspace?

 

 

Userlevel 4

I would still consider using the FeatureMerger for this scenario. The PythonCaller isn't really equipped to merge datasets, especially large datasets.

If you have several join cases, consider using e.g. a TestFilter to separate the different join cases and send them to different FeatureMergers set up for each join case.

If your data resides in a SQL database, you might also want to consider the SQLCreator and using database joins in your select statement. For large datasets this would be much faster than using a FeatureMerger.

Userlevel 2
Badge +17

Hi @nafise, if FME supports the data format, you could use the FMEUniversalReader class from FME Objects Python API to implement to read features from a dataset.

In personal opinion, however, generally there is no advantage to do so, since using the API class is equivalent to use a regular FME reader. Further, using a regular reader (or the FeatureReader transformer) would be much easier and also much more robust.

Why do you need to use the PythonCreator to read features from the datasets?

I've already answered to the question at first. That is, you can use the FMEUniversalReader class from FME Objects Python API to read features from a dataset.

 

However, I still think that there might be easier way. We could think of that, if you clarify the conditions for merging more specifically.

 

 

Hi @nafise, if FME supports the data format, you could use the FMEUniversalReader class from FME Objects Python API to implement to read features from a dataset.

In personal opinion, however, generally there is no advantage to do so, since using the API class is equivalent to use a regular FME reader. Further, using a regular reader (or the FeatureReader transformer) would be much easier and also much more robust.

Why do you need to use the PythonCreator to read features from the datasets?

I used "PythonCaller" transformer for creating a class and passed the two dataset to it and implemented my scenario. Hopefully it is working, before that I was thinking this transformer just was for creating a function, not a class. Thank you Takashi for all of your help

 

 

Reply