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

Announcements
Share your agentic AI experience, learn from others, and earn a new badge: Put Agentic AI to Work
cancel
Showing results for 
Search instead for 
Did you mean: 
AJ151
Contributor
Contributor

Writing data from tmap to multiple files

Hello all,

​

I have multiples files, i want to replace certain string in it and update the same.

Eg:

File 1 abcdef

File 2 sdabcd

File 3 jurabcdg

​

Final Output:

File 1 1ef

File 2 ad1

File 3 jur1g

​

Could anyone please help me with the logic using components or custom code? Iam new to talend as well as java. ​

Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi

If the data are stored in different files, you can use tFileList to iterate each file, eg:

tfilelist--iterate--tFileInputDelimited--tmap--tFileOutputDelimited

​

There are some global variables predefined on tFileList, such as:

current file path:(String)globalMap.get("tFileList_1_CURRENT_FILEPATH")

current file name: (String)globalMap.get("tFileList_1_CURRENT_FILE")

 

So, you can set the File name/Stream filed of tFileInputDelimited as:

(String)globalMap.get("tFileList_1_CURRENT_FILEPATH")

 

Set the file name field of tFileOutputDelimited like:

"D:/file/"+(String)globalMap.get("tFileList_1_CURRENT_FILE")+".txt"

 

Regards

Shong

View solution in original post

6 Replies
manodwhb
Champion II
Champion II

@Aneeta Joseph​ ,check the below solution.

 

 

0693p000008vf9bAAA.png

row1.col.replaceAll("abcd", "1") 

0693p000008vf9gAAA.png

 

 

Thanks,

Manohar

If you found my answer helpful, please give me a kudo ↑ Help others find answers faster by accepting my post as a solution √. Solved

AJ151
Contributor
Contributor
Author

Hello @Manohar B​ The logic seems good.. Could you please also help me with writing it to multiple files as per the input order?

AJ151
Contributor
Contributor
Author

@Xiaodi Shi @Shicong Hong​ @Richard Hall​ @Fred Trebuchet​ @Nikhil Thampi​ 

​

Hello All,

Sorry to​ tag you here. But could anyone please help with this? Iam stuck with this badly. Could see you in leaderboard, hope you could give me some solution for this.

​

Thanks in advance.

​

Regards,

Aneeta​

Anonymous
Not applicable

Hi

If the data are stored in different files, you can use tFileList to iterate each file, eg:

tfilelist--iterate--tFileInputDelimited--tmap--tFileOutputDelimited

​

There are some global variables predefined on tFileList, such as:

current file path:(String)globalMap.get("tFileList_1_CURRENT_FILEPATH")

current file name: (String)globalMap.get("tFileList_1_CURRENT_FILE")

 

So, you can set the File name/Stream filed of tFileInputDelimited as:

(String)globalMap.get("tFileList_1_CURRENT_FILEPATH")

 

Set the file name field of tFileOutputDelimited like:

"D:/file/"+(String)globalMap.get("tFileList_1_CURRENT_FILE")+".txt"

 

Regards

Shong

AJ151
Contributor
Contributor
Author

Thanks a lot for the response. Lemme try implementing the same. And will update you soon. ​

AJ151
Contributor
Contributor
Author

This works perfect. Hearty thanks. ​