Support Questions

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

Insert filename along with filecontent

avatar
Explorer

Dears,

 

I am loading a CSV file through get file processor and load data into a Singlestore database but  I have a requirement where I also have to insert the file name that I am loading into a column of the table in db along with the file content.

 

Thankyou!

3 REPLIES 3

avatar

hi @ushasri,

Can you provide some more details about your flow? Without knowing what you are doing in your flow, I can only tell you that you can use the Expression Language from NiFi and extract the filename of the flowfile and send it into your stream. The filename can be found as an attribute in each flowfile and can be called as ${filename}.
More about NiFi's Expression Language: https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html

avatar
Explorer

hi @cotopaul ,

 

    I am trying to insert file name in one of the column(file_name) of our table along with the data of the file. I have used ${filename} and have stored filename it but i want to insert it into a table.

 

Thankyou!

     

avatar

hi @ushasri,

What processor are you using to save the data within your DB and how do you build up the query? If you want to add the filename to the record which gets inserted within your table, you should use an UpdateRecord Processor to generate a new column and populate it using the ${filename}. Next, the generated record should go further down your line up until it gets inserted in your database.