Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Handle date column with spaces in nifi

avatar
Contributor

I am trying to  format the date field which contains spaces in replace text processor from a csv file. 

 

Got the error as it is unable to parse the date column which is spaces for first record. Please let me know how to handle this

 

Error message: Replace text failed to process session due to Cannot parse attribute value as a date; date format ddMMyyyy; attribute value:      

 

Input csv:

 

1,        , 123

2,02091997,234

 

Search value : (.{1}),(.{8}), (.{3}) 

Replacement value : $1, ${'$2':toDate("ddMMyyyy") :format("yyyy-MM-dd HH:mm:ss.SSS") }, $3

Replacement strategy : Regex Replace

Evaluation mode : Entire Text

 

1 ACCEPTED SOLUTION

avatar
Master Collaborator

Hi @Chakkara ,

 

What would you like the parser to do when it encounters an invalid date value? If this is a recurring problem, where multiple lines in your file have the same number of spaces to indicate missing date, then you can use ifElse in your replacement value command (something like this). 

 

 

Hope that helps,

Alex

View solution in original post

2 REPLIES 2

avatar
Master Collaborator

Hi @Chakkara ,

 

What would you like the parser to do when it encounters an invalid date value? If this is a recurring problem, where multiple lines in your file have the same number of spaces to indicate missing date, then you can use ifElse in your replacement value command (something like this). 

 

 

Hope that helps,

Alex

avatar
Contributor

Thanks for the response and it works!!