Support Questions

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

extract attribute value from file dynamically in nifi

avatar
Contributor

Hi,

 

I am trying to extract the single attribute(dynamic attribute passing) value from a JSON file or TEXT file .

 

The config file format looks like below

{

"product.csv" :"INSERT INTO Product",

"Wholesale.csv" :"INSERT INTO Wholesale"

}

 

The above JSON can evolve based new sources files and can added many file names with respective hive queries .

I have config file at shareserver and able to retrieve the into middle of the nifi flow as per the attached screen-print . I able to retrieve the attribute values using Evaluate JSON path with fixed number of attributes . But the attribute value can be changed and i can't configure the same attribute name in Evaluate JSON path processor . I understand that getting attribute value by dynamically passing attribute names not possible in nifi processor like JSON to Attributes .

https://community.cloudera.com/t5/Support-Questions/Nifi-Dynamic-Attribute-Creation/m-p/198062#M1601...

 

Nififlow.PNG

 

I know that below JSON path is wrong for product.csv and it should be like $.product.csv . Assume that before Fetchconfig , i will update the "filename1" attribute to product.csv or wholesale.csv or any filename in Updateattribute processor . Using that attribute , i need to get the value from the config file dynamically .

EvaluateJSON.PNG

I would need some work around to pass dynamic "filename" as attribute and extract the values for that attribute and store into next processor flowfile attribute or flowfile content . I am still new to Nifi expression language . Please assist . Currently i need to retrieve 1 attribute value passing dynamic attribute value like filename

@MattWho 

 

1 REPLY 1

avatar
Master Guru