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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
ashif2
Creator II
Creator II

tFileOutputDelimited converts null values to empty strings.

Hi Gurus,

Talend converts null values into empty strings when we configure the tFileOutputDelimited to write the data with text enclosures . Say , if integer column is having null values, when I write this integer column into csv file using tFileOutputDelimited with csv options enabled.

null value in the integer turns into "". empty string..

tFileOutputDelimited compontent is enclosing the numeric columns within double quotes. which is wrong.

 

For example below is source data, when we transform the json data into csv with text enclosures (age is integer column)

[

{

"name" : "john",

"age":22,

"city":"London"

},

{

"name" : "leon",

"age": null ,

"city":"Brighton"

}

]

Expected output in csv :

name,age,city

"John",22,"Lonon"

"leon",,"Brighton

Actual Output in talend is:

name,age,city

"John","22","Lonon"

"leon","","Brighton -------------> here null value in the force is converted to empty string.

How to resolve this use ?

Labels (5)
3 Replies
Anonymous
Not applicable

hello

There is no an option on tFileOutputDelimted to fix this issue directly, a workaround is:

create a temporary file, then read this temporary as a string using tFileInputRaw and replace the double quotes with empty value on a tJavaRow, and output the string a CSV file using tFIleOutputRaw.

0695b00000Uy1bDAAR.png 

Regards

Shong

ashif2
Creator II
Creator II
Author

Hi Shong,

 

This fix won't work always.

 

 

[

{

"name" : "john",

"age":22,

"city":"London",

"country": "UK"

},

{

"name" : "leon",

"age": null ,

"city":"Brighton",

"country":""

}

]

 

 

 

Data from upstream is sending the empty string for some of the string columns . This fix will convert the empty string to null.

 

Talend should include a option in the tFileOutput delimiter on treating the null values. "Don't enclose null values within field enclosures".

 

 

 

 

howieS1
Contributor
Contributor

try this:

output_row.content = input_row.content.toString().replaceAll("\"\"","null");