Problem in tFileList

Highlighted
Six Stars

Problem in tFileList

hello All..

I have a folder having many sub folders. Each sub folder have a single file having the same name.

for example only one folder then 100 sub folders and each sub folder has a file so total 100 files and name is same for all files like "file.xml" 

i have designed a job which is coverting xml files to json

tFileList--tFileInputXML--tMap-- tWriteJsonField-- tFileOutputDelimited

now the  problem is as it should processed 100 files but as output i am getting only one output file.It may be because all files have the same name.

Please tell me the solution what should i do so that i can get all 100 Jsons (desired output)

please help me as soon as possible.


Accepted Solutions
Highlighted
Sixteen Stars
Sixteen Stars

Re: Problem in tFileList

You  need to extract it from the "CURRENT_FILEDIRECTORY" global variable associated to the tFileList using the substring method.

Based on the previous example, it should look like this:

"File_"+
((String)globalMap.get("tFileList_1_CURRENT_FILEDIRECTORY")).
substring(((String)globalMap.get("tFileList_1_CURRENT_FILEDIRECTORY")).
lastIndexOf("\\")+1)+
".xml"

TRF

View solution in original post


All Replies
Highlighted
Sixteen Stars
Sixteen Stars

Re: Problem in tFileList

Hi,

You may include the file number issued from tFileList into the output filename like this:

"file_" + ((Integer)globalMap.get("tFileList_1_NB_FILE")) + ".xml"

This suppose the output filename is constructed into the tFileList iteration.

Hope this helps.


TRF
Highlighted
Six Stars

Re: Problem in tFileList

hey thanku so much..

now its working fine...but how can i add the sub folder name instead of file number in the output file name.

 

Highlighted
Sixteen Stars
Sixteen Stars

Re: Problem in tFileList

You  need to extract it from the "CURRENT_FILEDIRECTORY" global variable associated to the tFileList using the substring method.

Based on the previous example, it should look like this:

"File_"+
((String)globalMap.get("tFileList_1_CURRENT_FILEDIRECTORY")).
substring(((String)globalMap.get("tFileList_1_CURRENT_FILEDIRECTORY")).
lastIndexOf("\\")+1)+
".xml"

TRF

View solution in original post

Highlighted
Six Stars

Re: Problem in tFileList

hi can you add the subfolder name as below

 

((String)globalMap.get("tFileList_1_CURRENT_FILEDIRECTORY"))+"\\"+((String)globalMap.get("tFileList_1_CURRENT_FILE"))

Highlighted
Sixteen Stars
Sixteen Stars

Re: Problem in tFileList

@shalla, did it help you?

In this case thank's to mark this case as resolved (Kudos also accepted).


TRF
Highlighted
Six Stars

Re: Problem in tFileList

thanku @TRF it is solved

 

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog