Five 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.

1 ACCEPTED SOLUTION

Accepted Solutions
Thirteen Stars TRF
Thirteen 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
6 REPLIES
Thirteen Stars TRF
Thirteen 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
Five 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.

 

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

Thirteen Stars TRF
Thirteen 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
Five Stars

Re: Problem in tFileList

thanku @TRF it is solved