Problem in tFileList

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
Fifteen Stars TRF
Fifteen 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

All Replies
Fifteen Stars TRF
Fifteen 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
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.

 

Fifteen Stars TRF
Fifteen 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
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"))

Fifteen Stars TRF
Fifteen 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
Six Stars

Re: Problem in tFileList

thanku @TRF it is solved

 

2019 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch