on 02-28-2023 6:20 PM
Hello everyone, I need your help. I am taking from the client's SFTP a file with a .CSV extension which brings the following content
EMPLOYEE_ID,DAYS_OFF,WORK_DT,INDICATOR,BATCH_ID
"1047,""1"",""2023-01-22"",""I"",""2363281998"""
"1139,""1"",""2022-11-27"",""I"",""2363281998"""
"1139,""1"",""2023-01-15"",""I"",""2363281998"""
"1139,""1"",""2023-01-29"",""I"",""2363281998"""
"1139,""1"",""2023-02-19"",""I"",""2363281998"""
"1223,""1"",""2023-02-26"",""I"",""2363281998"""
"1428,""1"",""2023-02-19"",""I"",""2363281998"""
I need to somehow remove all the double quotes (") that are in the file. That is, it looks like this.
EMPLOYEE_ID,DAYS_OFF,WORK_DT,INDICATOR,BACTH_ID
1047,1,2023-01-22,I,2363281998
1139,1,2022-11-27,I,2363281998
1139,1,2023-01-15,I,2363281998
1139,1,2023-01-29,I,2363281998
1139,1,2023-02-19,I,2363281998
1223,1,2023-02-26,I,2363281998
1428,1,2023-02-19,I,2363281998
Could you help me with a groovy script or some function that allows me to modify the payload in this way? since in the next step there is a CSV to XML converter and if the payload arrives with the double quotes (") it generates an error
Hi jdforero - Would you add the below JavaScript to replace all the double quotes from the message body?
importClass(com.sap.gateway.ip.core.customdev.util.Message);
importClass(java.util.HashMap);
function processData(message) {
//Get and Set the Body
var getBody = String(message.getBody( new java.lang.String().getClass()));
var replaceDoubleQuots = getBody.replace(/"/g, "");
message.setBody(str)
return message;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
77 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.