I have a question, i am trying to join in a pythoncaller
Only i am getting this error:
BADNEWS: Cannot convert null string into an integer
(C:\code\fme\foundation\framework\util\stf\stfutil.cpp:347) class StatusInfo *__cdecl STF_stringToUInt(const class ObsoleteString &,unsigned int &)
Python Exception <AttributeError>: 'fmeobjects.FMEFeature' object has no attribute 'getAllAttributes'
Traceback (most recent call last):
File "<string>", line 14, in input
AttributeError: 'fmeobjects.FMEFeature' object has no attribute 'getAllAttributes'
Error encountered while calling method `input'
PythonCaller_FeatureMergerReplacement (PythonFactory): PythonFactory failed to process feature
The script i am using is:
import fme
import fmeobjects
import pandas as pd
class FeatureMergerReplacement(object):
def __init__(self):
# Initialiseer de DataFrames
self.primary_df = pd.DataFrame()
self.secondary_df = pd.DataFrame()
def input(self, feature):
# Voeg rij toe aan primary_df
new_row = pd.DataFrame([feature.getAllAttributes()], columns=feature.getAllAttributeNames())
self.primary_df = pd.concat([self.primary_df, new_row], ignore_index=True)
def input2(self, feature):
# Voeg rij toe aan secondary_df
new_row = pd.DataFrame([feature.getAllAttributes()], columns=feature.getAllAttributeNames())
self.secondary_df = pd.concat([self.secondary_df, new_row], ignore_index=True)
def close(self):
# Voer de join-operatie uit
self.merged_df = pd.merge(self.primary_df, self.secondary_df, on='ObservationID', how='inner')
# Itereer over elke rij in het resultaat en stuur terug naar FME
for index, row in self.merged_df.iterrows():
feature = fmeobjects.FMEFeature()
for col in self.merged_df.columns:
feature.setAttribute(col, row[col])
self.pyoutput(feature)