Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Roger_Sheets
Contributor
Contributor

Getting filename Using File Source

has anyone found a way to capture the filename as a column when you're importing from a file?

we get daily files that all have the "date" as part of the filename .. i'd love to be able to capture the entire filename (heck even the entire path & filename would be acceptable) so i know exactly which file a record comes from.

i've heard you can do something file preprocessing on the connection, but thats thru powershell, and i dont know that very well.

i cannot believe the filename of all things isnt a parameter that's just captured by default .. Replicate certainly has to know the filename to open it and pull data from it.

5 Replies
therealdees
Creator III
Creator III

If you're working in script level you can use the function FileName to extract the name of the file that is feeding the table:

 

https://help.qlik.com/en-US/qlikview/May2023/Subsystems/Client/Content/QV_QlikView/Scripting/FileFun...

Roger_Sheets
Contributor
Contributor
Author

not sure what you mean .. at a script level .. this is in replicate using "file" as a source .. QlikView has different options i think.

therealdees
Creator III
Creator III

If you're working inside Qliks environment, specifically at the loader script while loading tables.

If you need to extract the file name of a file that is feeding a table you're loading, you can use the above function to do so. If you need to do it outside QlikView or Sense, not really sure then, sorry.

Heinvandenheuvel
Specialist III
Specialist III

@therealdees - You are replying to a Qlik REPLICATE topic. Not Qlikview - This is a different (more fun) animal!

@Roger_Sheets Check the PRE PROCESSING option in the ADVANCE TAB.

Be sure to read the Userguide many time, very carefully. It's not too hard, but details matter (as always)

Setting up a File Pre-processing Command
Your program will be executed on each of the input files, and should accept the following parameters:
l The location of the input file(s) (as specified in the Location of full load data file(s) and/or the Change
File location)
l The full path of the output file
The output file(s) will be written to the following location:
PRODUCT_INSTALLATION\data\tasks\TASK_NAME\trans_files\OUTPUT_FILE_NAM

john_wang
Support
Support

Hello @Roger_Sheets ,

I agree with @Heinvandenheuvel , personally I do not think it's easy to get the file name dynamically. How about add the file name as one additional column value(s) by file preprocessing option.

Hope this helps.

John.

 

Help users find answers! Do not forget to mark a solution that worked for you! If already marked, give it a thumbs up!