如何在 Apache NiFi 中使用 Python 和 pandas 将 CSV 转换为 Excel?

How to convert CSV to Excel using Python with pandas in Apache NiFi?

如何使用处理器 ExecuteStreamCommandExecuteScript 将 CSV 原始源从 GenerateFlowFile 处理器转换为 Excel 文件?

以及如何运行Python虚拟环境(env)在Python项目中使用依赖项?

在 Python 脚本中将 CSV 包装成 Excel 逻辑,并使用 ExecuteStreamCommand 调用它。开始类似下面的内容并根据您的要求进行更改:

import pandas as pd

# Reading the csv file content from NiFi
csv_df = pd.read_csv(sys.stdin)
  
# send excel file back to NiFi
csv_df.to_excel(sys.stdout.buffer, index=False)

将您的 ExecuteStreamCommand 处理器配置为: