在nifi中处理带有空格的日期列

Handle date column with spaces in nifi

我正在尝试格式化包含空格的日期字段以替换来自 csv 文件的文本处理器。

收到错误,因为它无法解析作为第一个记录的空格的日期列。请让我知道如何处理这个

错误消息:由于无法将属性值解析为日期,替换文本无法处理会话;日期格式 ddMMyyyy;属性值:

输入 csv:

1,        , 123

2,02091997,234

搜索值:(.{1}),(.{8}), (.{3})

替换值:, ${'':toDate("ddMMyyyy") :format("yyyy-MM-dd HH:mm:ss.SSS") },

替换策略:正则表达式替换

评价模式:全文

您可以使用语言表达式中的 isEmptyifElse 函数。

例如:${'':isEmpty():ifElse('null', '':toDate("ddMMyyyy"):format("yyyy-MM-dd HH:mm:ss.SSS")) }

这里我放的是'null',没有日期的时候,你可以选择你想要的值。

However, if you can, parse your CSV files with a CSVReacordReader which handle that out of the box.