Five Stars

How to insert tfilelist variable in table

Hi guys,

 

I'm Using a tFileList and a tFileInputPositional to read files from some subfolders and Insert the data in a sql table.

I would like to insert also in the sql table a new column with the folder name (given by the tFileList).

How can I do that?

I leave you with a print of my job:

Sem Título.png

Thanks,
Miguel Cunha

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Seven Stars sgv
Seven Stars

Re: How to insert tfilelist variable in table

You have to map your data ...  just with drag and drop

Capture.PNG

 

6 REPLIES
Community Manager

Re: How to insert tfilelist variable in table

Hi
Add a tMap before tDBxxxOutput component, add a new column and set its expression with the global variable.

Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars

Re: How to insert tfilelist variable in table

@shongthank you for your help.

I did what you say but the output was null for all columns.

Am I doing something wrong?

 

Sem Título.png

Seven Stars sgv
Seven Stars

Re: How to insert tfilelist variable in table

You have to map your data ...  just with drag and drop

Capture.PNG

 

Five Stars

Re: How to insert tfilelist variable in table

@sgvStill not working. Smiley Sad

Now all columns ourtuput is ok, except the variable one.

Is the variable ok? ((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))

Seven Stars sgv
Seven Stars

Re: How to insert tfilelist variable in table

It's depend of the name of your variable.
So your tFileList have a Talend Name and a Personnal name (default : personnal name = talend name).
for exemple :  Capture.PNG

Here, personnal name is "azerty" and TalendName is "tFileUnarchive_1"

 

So what is the purpose of that :

When you want to use a global variable, you have just to write this : "azerty." and then if you press "Ctr+space", talend will give you every global var generated  by the component.

like this :

Capture.PNG

 

Then, you have juste to choise the global var needed, and Talend will give you the appropriate code. In this case, I want the CURRENT_FILEPATH : ((String)globalMap.get("tFileUnarchive_1_CURRENT_FILEPATH"))

 

 

It's really important to understand that if you want to use global var from component.

 

In your case, maybe you can rename your tFileList with a name variable more appropriate, like ListeFile

And then in your tMap try to write "ListeFile." and press "Ctr+Space"

Good luck

SGV

Five Stars

Re: How to insert tfilelist variable in table

@sgvThank you very much. I already made it but your answer made me understand a little more about those variables.

Smiley Happy