【发布时间】:2020-06-10 09:06:30
【问题描述】:
我正在尝试将一个流文件拆分为多个流文件,基础是在即将到来的流文件中添加一个月的日期。
例如。 {"to":"2019-12-31T00:00:00Z","from":"2019-03-19T15:36:48Z"} 是我在流文件中得到的日期。所以我必须将此单个流文件拆分为 11 个具有日期范围的流文件,例如
{"to":"2019-04-19","from":"2019-03-19"}
{"to":"2019-05-19","from":"2019-04-19"}
{"to":"2019-06-19","from":"2019-05-19"}
....... and so till
{"to":"2019-12-31","from":"2019-12-19"} .
我一直在尝试使用示例输入将文件拆分为日常流文件:
`
begin = '2018-02-15'
end = '2018-04-23'
dt_start = datetime.strptime(begin, '%Y-%m-%d')
dt_end = datetime.strptime(end, '%Y-%m-%d')
one_day = timedelta(days = 1)
start_dates = [dt_start]
end_dates = []
today = dt_start
while today <= dt_end:
tomorrow = today + one_day
print(tomorrow)
`
但我的 Execute 脚本处理器出现错误。 nifi flow screenshot
【问题讨论】:
标签: datetime apache-nifi jython timedelta execute-script