Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Add column with CSV name

I have been tasked to perform ETL on a data set that has 10 CSV files with the same information, its just from different countries.

My Question is, how would you populate an extra column in your Dimension table with the name of the CSV file. 

 

Thank You 

Labels (3)
1 Solution

Accepted Solutions
sonalijagtap
Contributor III
Contributor III

Hi Shriya,

 

Please refer below similar solution to add file name for record.

 

0683p000009M3MD.png

 

tMap Setting:

Add below global Variable of tFileList to get the current file name

0683p000009M2wM.pngtMap Setting

Kindly let me know whether it answers your question or not.

 

Thank You,

Sonali Jagtap

 

 

 

 

 

 

View solution in original post

9 Replies
akumar2301
Specialist II
Specialist II

Can you please explain your query wih example? There could be different understandings of your query.

Are you using tfilelist in your job?

Anonymous
Not applicable
Author

I have different CSV files with their name being different countries, i am using a tfilelist and them connecting tat to a tFileInputDelimited them mapping to my dimensinon table, where i want to create a new row titles country and populate it with the csv file name, e.g. Canada.csv to a column where all the records belonging to the Canada table had Canada in that column.

akumar2301
Specialist II
Specialist II

Add a tjavarow or tmap after your inputfilecomponent.

Add additional col filename , map it to expression of filename which you
used in input component.

Output_row.Filename = globalvar of tfilelist_1_CURRENT_FILE

You could remove extensions but split command
Filename.split(“.”)[0]
sonalijagtap
Contributor III
Contributor III

Hi Shriya,

 

Please refer below similar solution to add file name for record.

 

0683p000009M3MD.png

 

tMap Setting:

Add below global Variable of tFileList to get the current file name

0683p000009M2wM.pngtMap Setting

Kindly let me know whether it answers your question or not.

 

Thank You,

Sonali Jagtap

 

 

 

 

 

 

Anonymous
Not applicable
Author

Hi

 

I did that but I am outputting to a tMsSqlOutput, it is populating the row with a null.

akumar2301
Specialist II
Specialist II

Can you please put tlogrow before tmssqloutput and check if it is coming
null.

And put sceenshot of your job. It must be small issue
Anonymous
Not applicable
Author

This is the error I am Getting.

I used ((String)globalMap.get("tFileList_1_CURRENT_FILE")) and the error, how ever when i used 

((String)globalMap.get("tFileList_1_CURRENT_FILEPATH")) it did output the file name.


NAME.PNG
akumar2301
Specialist II
Specialist II

thats correct

 

current_filepath should be used in tfileinput component as it has absolute filename including path.below link will help. 

 

https://help.talend.com/reader/mjoDghHoMPI0yuyZ83a13Q/s88XQGiwRClewQ1MPT6I2A

 

however to get only file name , you could use current_file globalvar. 

Anonymous
Not applicable
Author

Thanks for the help.

I'm fairly new to Talend can you please explain how i would use current_file globalvar to give the column name just the file name and not the path.