Hi Friends,
I have scenario, where I am reading the flowfile using python script from ExecuteStreamCommand, then after doing some operation on the dataframe I want send back the data type as flowfile which should be of type xlsx.
In my correct scenario the python script simply passing object of the xlsx file to ExecuteStreamCommand, as " <pandas.io.excel._xlsxwriter._XlsxWriter object at 0x000001C856D99E88> "
the code snippet is ...
import sys, csv;
import pandas as pd
class CustomPythonScript():
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
pd.set_option('display.max_colwidth', -1)
df = pd.read_csv(sys.stdin, sep='\t')
data = df.groupby(['X_temp250', 'Y_DT_temp250', 'Z_temp250', 'X_temp350', 'Y_DT_temp350', 'Z_temp350']) \
.sum(numeric_only=True).reindex(columns=set(df.columns) - {'X_temp250', 'Y_DT_temp250', 'Z_temp250',
'X_temp350', 'Y_DT_temp350',
'Z_temp350'}).reset_index()
df1 = pd.DataFrame(data)
writerExcel = pd.ExcelWriter('report_groupby.xlsx', engine='xlsxwriter')
df1.to_excel(writerExcel, sheet_name='report_groupby', index=False)
writerExcel.save()
print(writerExcel)