- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Handle date column with spaces in nifi
- Labels:
-
Apache NiFi
Created on ‎07-06-2021 05:29 AM - edited ‎07-06-2021 05:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Created ‎07-06-2021 10:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Created ‎07-06-2021 10:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Created ‎07-07-2021 01:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the response and it works!!
