Created 11-22-2022 04:17 AM
Hi,
I have the below data:
Record 6|Invalid values for Entry Date.
Record 7|Processing failed due to error in record: 6
Record 8|Processing failed due to error in record: 6
Record 9|Processing failed due to error in record: 6
Record 10|Processing failed due to error in record: 6
Record 11|Duplicate of record Job id : , data id : , first_name: , last_name: , Date: 2021, Entry Date: 2021.
Record 12|Processing failed due to error in record: 11
Record 13|Processing failed due to error in record: 11
Record 14|Processing failed due to error in record: 11
Record 15|Processing failed due to error in record: 11
I want to convert it like:
[
{
"Record 6":"Invalid values for Entry Date."
},
{
"Record 7":"Processing failed due to error in record: 6"
},
{
"Record 8":"Processing failed due to error in record: 6"
},
{
"Record 9":"Processing failed due to error in record: 6"
},
{
"Record 10":"Processing failed due to error in record: 6"
},
{
"Record 11":"Duplicate of record Job id : , data id : , first_name: , last_name: , Date: 2021, Entry Date: 2021."
},
{
"Record 12":"Processing failed due to error in record: 11"},
{
"Record 13":"Processing failed due to error in record: 11"},
{
"Record 14":"Processing failed due to error in record: 11"},
{
"Record 15":"Processing failed due to error in record: 11"}]
How can I do that. Please help
Created on 11-23-2022 02:40 AM - edited 11-23-2022 02:57 AM
Hello,
quick and dirty solution:
In Apache Nifi there you can find the SplitText Processor, there you can set the Line Split Count to 1.
Those splitted Flowfiles get some fragment attributes to merge them together again. So after splitting you can merge directly again with MergeContent Processor.
For this processor you set properties like:
- Merge Strategy: Defragment
- Delimiter Strategy: Text
- Header: [{"
- Footer: "}]
- Demarcator: "},{"
After that we can split key values with ReplaceText Processor with following properties what needs to be changed from default:
- Search Value: \|
- Replacement Value: ":"
Greetings
Created on 11-23-2022 02:40 AM - edited 11-23-2022 02:57 AM
Hello,
quick and dirty solution:
In Apache Nifi there you can find the SplitText Processor, there you can set the Line Split Count to 1.
Those splitted Flowfiles get some fragment attributes to merge them together again. So after splitting you can merge directly again with MergeContent Processor.
For this processor you set properties like:
- Merge Strategy: Defragment
- Delimiter Strategy: Text
- Header: [{"
- Footer: "}]
- Demarcator: "},{"
After that we can split key values with ReplaceText Processor with following properties what needs to be changed from default:
- Search Value: \|
- Replacement Value: ":"
Greetings
Created 11-23-2022 02:51 AM