I cannot understand what you intend to achieve with this code.
feature.setAttribute('Format[subfolder]',result)
If the 'feature' is an instance of fmeobjects.FMEFeature class, the code above performs to assign the value contained by a variable called 'result' to a feature attribute named 'Format[subfolder]'.
Is it actually your intention? If so, what value does the variable 'result' contain, and how did you create the value in the script?
Hi @takashi
My example is read Hierarchical from a file :
Format = Brasilia.dat
Subfolder = /Month / Day ( Hierarchical from Brasilia.dat )
How can I read this structure in PythonCaller, instead in PyCharm it works :
result = Format [subfolder]
Thanks your help
Hi @takashi
My example is read Hierarchical from a file :
Format = Brasilia.dat
Subfolder = /Month / Day ( Hierarchical from Brasilia.dat )
How can I read this structure in PythonCaller, instead in PyCharm it works :
result = Format [subfolder]
Thanks your help
I don't know what the Hierarchical is, but the same codes should also work with a PythonCaller, if those work as expected with PyCharm debugger. Of course, you have to import the same module(s) that you are using in the source tested with PyCharm.
I cannot understand what you intend to achieve with this code.
feature.setAttribute('Format[subfolder]',result)
If the 'feature' is an instance of fmeobjects.FMEFeature class, the code above performs to assign the value contained by a variable called 'result' to a feature attribute named 'Format[subfolder]'.
Is it actually your intention? If so, what value does the variable 'result' contain, and how did you create the value in the script?
Hi @takashi
My code is:
def processFeature(feature):
with h5py.File(Format,'r') as f:
feature.setAttribute('f[subfolder]',result)
But the attribute result doenst show nothing.
Thanks,
Danilo
I cannot understand what you intend to achieve with this code.
feature.setAttribute('Format[subfolder]',result)
If the 'feature' is an instance of fmeobjects.FMEFeature class, the code above performs to assign the value contained by a variable called 'result' to a feature attribute named 'Format[subfolder]'.
Is it actually your intention? If so, what value does the variable 'result' contain, and how did you create the value in the script?
Looks like you intend to retrieve a group called 'subfolder' recorded in an HDF5 file using the 'h5py' module.
Assuming that the input feature has an attribute called "_hdf5filepath" storing file path to the source HDF5 file which contains a group named 'subfolder', this script retrieves the content of 'subfolder' group and saves it as a string value into a new attribute called "f[subfolder]".
import h5py
def processFeature(feature):
Format = feature.getAttribute('_hdf5filepath')
with h5py.File(Format, 'r') as f:
group = f['subfolder']
feature.setAttribute('f[sobfolder]', '%s' % group)
Since FME Desktop doesn't bundle the 'h5py' module by default, you have to install the package to your FME Desktop.
Installing Python Packages to FME Desktop
And see here to learn more how to use the 'h5py' module:
HDF5 for Python