One Star

Int to Doube/Char to Boolean

Hello all,
I have an excel(sheet) as my input and SFDC connection as my output with a tMap in between.
Currently it error's because it can't convert between the data types.
Type mismatch: cannot convert from String to Double
Type mismatch: cannot convert from Character to boolean
I'm trying different ways with the tMap component in the expression part to get these convert but am not having much luck.
Does anybody have any ideas to help me.
Regards Lee
9 REPLIES
Community Manager

Re: Int to Doube/Char to Boolean

Hi
Can you show us the expression you are using to convert the data type?
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Int to Doube/Char to Boolean

Thank you for the reply.
Type mismatch: cannot convert from String to Double
Double.parseDouble(row7.DELIVERED_COST)
Type mismatch: cannot convert from Character to boolean
row7.SPECULATIVE_BUILD__C("Y")?1:row7.SPECULATIVE_BUILD__C("N")?0:Null
One Star

Re: Int to Doube/Char to Boolean

The first error you posted (Type mismatch: cannot convert from String to Double
Double.parseDouble(row7.DELIVERED_COST) ) is usually an issue with your field types. Double click your tMap to open it, then look at the bottom where it shows the Schema editor. Here you will see all your fields; they all have types associated with them like String, Double, Int, etc. You can change them by choosing another type from the dropdown menu (right beside the field names).
Make sure that they fields are the correct type. I.e. make sure on the tMap the field that you are mapping this to "Double.parseDouble(row7.DELIVERED_COST)" is set to a double.
As for the other line "row7.SPECULATIVE_BUILD__C("Y")?1:row7.SPECULATIVE_BUILD__C("N")?0:Null" you're not actually comparing anything. I think you meant:
row7.SPECULATIVE_BUILD__C.equals("Y")?1:row7.SPECULATIVE_BUILD__C.equals("N")?0:Null
One Star

Re: Int to Doube/Char to Boolean

Thank you,
The field is mapped to a double but still errors.
After doing more research i see others have used a tConvertType would this help both my issues ?
Lee
One Star

Re: Int to Doube/Char to Boolean

Thank you,
The field is mapped to a double but still errors.
After doing more research i see others have used a tConvertType would this help both my issues ?
Lee

Could you upload a screenshot of your tMap window? I don't think the tConverType is necessary. I made some edits to my first post and I mentioned that for your second issue, you aren't comparing any fields. Did you mean to include a .equals()?
One Star

Re: Int to Doube/Char to Boolean

This is for the int to boolen.
One Star

Re: Int to Doube/Char to Boolean

That expression looks right. Are you still getting an error about a Boolean? Also could you attach a screenshot of what you see when you double click your tMap?
One Star

Re: Int to Doube/Char to Boolean

Ok got the boolean working. By using this.
row4.Spec_Build.equals("Y")?true:row4.Spec_Build.equals("N")?false:null
Now just need to work on integer to double.
One Star

Re: Int to Doube/Char to Boolean

It's going to be much easier to help you if you can take a screenshot of your tMap, making sure you drag the Schema editor so we can see all the fields. This is an example of mine: