Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello All,
Thanks to this wonderful forum in advance.
I have converted a JSON to CSV file with comma separated string values which contains null at the end or in middle, so I want to remove the null without touching the character which may consist "null" inside the word.
Input
Object_id, attribute_value
001,"hello world,null"
002,"you can ignore nullable date,null"
Expected output
Object_id, attribute_value
001,"hello world,"
002,"you can ignore nullable date,"
I tried to use tReplace but it removes the null from the string as well making it
002,"you can ignore able date," ----->
incorrectIs there any other way I can handle the null?
Regards
SD3156
Hi as null is at the end of the string you can try "null$" in the tReplace.
Hi as null is at the end of the string you can try "null$" in the tReplace.
you can also try something like this in a tJavaRow :
String[] arrays=
(input_row. attribute_value).split(",");
String ent = "";
for(int i=0;i< arrays.length;i++)
{
if(!("null").equals(arrays[i]))
ent = ent + arrays[i] + ",";
};
output_row.Object_id = input_row.Object_id;
output_row. attribute_value = ent.replaceAll(",$","");
gjeremy1617088143 thanks this trick worked for all the values ending with 'null'