Support Questions

Find answers, ask questions, and share your expertise

Getting information from CSV to enrich JSON in Nifi

New Contributor

Hi there

 

I've got a bunch of JSON FlowFiles with arrays in that looks like this:

 

[

{"TagName":"mytag","TagEpoch":1629644712,"Value":28.455127716064453},

{"TagName":"mytag2","TagEpoch":123,"Values":12.12313132123123},

{"TagName":"mytag","TagEpoch":123,"Value":23.132123123},

...

]

 

Then I also have a CSV file that contains meta information about the tag like this:

 

TagName,Position,Area,...
mytag,A,TagGroup1,...
mytag2,B,TagGroup1,...

 

I want to combine the two to get a JSON object that looks something like this:

[
    {
        "TagName": "mytag",
        "TagEpoch": 123,
        "Value": 27.123123123,
        "Area": "TagGroup1",
        "Position": "A",
    },
    {
        "TagName": "mytag1",
        "TagEpoch": 123123123,
        "Value": 82.123123123,
        "Area": "TagGroup1",
        "Position": "A",
    },
    {
        "TagName": "mytag2",
        "TagEpoch": 123,
        "Value"; 12.123123123123,
        "Area": "TagGroup1",
        "Position": "B"
    },
    ...
]

I've thought about using RecordLookup and created a CSV lookup service like this:

cverster_0-1629640504236.png

where AzureFolderName is one of the items I want to read out of the CSV, and the CSV lookup service is configured like this:

cverster_1-1629640579974.png

But the outcome doesn't include AzureFolderName from the CSV, only the original JSON inputs.

 

How can I use the TagName to get additional information from a CSV / JSON file and add it to the JSON object?

0 REPLIES 0
Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.