Created 04-18-2023 01:05 AM
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!
Created 04-18-2023 02:38 AM
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
Created 04-18-2023 03:02 AM
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!
Created 04-18-2023 05:07 AM
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.