Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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
@Aneeta Joseph ,check the below solution.
row1.col.replaceAll("abcd", "1")
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
Hello @Manohar B The logic seems good.. Could you please also help me with writing it to multiple files as per the input order?
@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
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
Thanks a lot for the response. Lemme try implementing the same. And will update you soon.
This works perfect. Hearty thanks.