Delete white spaces in a tFileInputDelimited

Two Stars

Delete white spaces in a tFileInputDelimited

Hi! I have a job with a tFileInputDelimited; some fields of this file have white spaces and when I run the job in Talend 5.4.1 get null values. Fields are BigDecimal type. How can I solve this?
I attach some pictures of file and output of null values. The fields are in yellow.
Thank you.
Regards
Highlighted
One Star

Re: Delete white spaces in a tFileInputDelimited

Deleting white spaces is easy, you can just do FieldName.replaceAll(" ","") or FieldName.replaceAll("\\s","") if the white space is some character other than a common space. I'm not sure why you're getting the null error though, sorry I couldn't help more.

However since you're performing manipulations on the fields so if you have an empty field you'll get a nullpointerexception error. To fix that you just need to check if the field is empty, like this:
!Relational.ISNULL(FieldName) ? FieldName.replaceAll("\\s","") : null
Basically that checks if the field isn't null. If it isn't, it removes the whitespaces. However if the field is null, then it adds a null value without giving you a nullpointer exception.
Two Stars

Re: Delete white spaces in a tFileInputDelimited

I tried this solution but doesn't work; Talend still shows null values on console.
Thank you for your sugestion
Four Stars

Re: Delete white spaces in a tFileInputDelimited

Hi,
If the field is big decimal, you can remove the white spaces.
- First need to convert/parse your input fields to string type
- Delete white spaces using java trim/replace
- Convert back to original data type
Your middle column in the screenshot does not look like double, instead has a "-" in the field contents
Have you created metadata for your input file and able to view contents?
Try this.
Vaibhav