0

enter image description here

I have been trying to get an excel file and process it using a python script in executestreamcommand. but it is showing this error.

Any idea on how to read excel file to stdin?

ExecuteStreamCommand Configuration

import pandas as pd
import openpyxl

df = pd.read_excel(sys.stdin)
df.to_csv(sys.stdout, index=False, header=True)
  • `stdin` is an input stream. You can read from it. You should always expect a write to stdin to fail. – William Pursell Jun 04 '21 at 12:17
  • That is a terrible error message. I believe it means that the pipe has been closed, almost certainly because the process that is reading from it has terminated. It sounds like your python script is terminating prematurely. – William Pursell Jun 04 '21 at 12:21
  • 1
    Share your ExecuteStreamCommand config and script? – Sdairs Jun 04 '21 at 13:08
  • 1
    How you have configured `ExecuteStreamCommand ` processor, can you please add it to the question! – Vikramsinh Shinde Jun 04 '21 at 13:18
  • To read flowfile content, you can use something like - `wb = xlrd.open_workbook(file_contents=sys.stdin.read(),logfile=open(os.devnull, 'w')) excel_file_df = pd.read_excel(wb, sheet_name='Sheet1', index=False, index_col=0, encoding='utf-8',engine='xlrd') #flowfile_content = ExcelFile(BytesIO(sys.stdin.read())) #excel_file_df = pd.read_excel(flowfile_content, sheet_name='Sheet1', index=False, index_col=0, encoding='utf-8')` – Vikramsinh Shinde Jun 04 '21 at 13:24
  • I've added some changes – Aakarsh Raj Jun 07 '21 at 11:35

0 Answers0