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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
SD3156
Contributor II
Contributor II

remove null from comma separated csv file without removing the "null" from string

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," ----->

incorrect

Is there any other way I can handle the null?

Regards

SD3156

Labels (2)
1 Solution

Accepted Solutions
gjeremy1617088143

Hi as null is at the end of the string you can try "null$" in the tReplace.

View solution in original post

3 Replies
gjeremy1617088143

Hi as null is at the end of the string you can try "null$" in the tReplace.

gjeremy1617088143

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(",$","");

SD3156
Contributor II
Contributor II
Author

gjeremy1617088143 thanks this trick worked for all the values ending with 'null'