
Anonymous
Not applicable
‎2012-05-04
03:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
String to Double conversion in tmap
Hi,
I have 25 columns and have a requirement where in we need to search for a value in every column. Like if "Fuel Surcharge" is in ABCD then consider the amount value from the column ABCD_1, or if "Fuel Surcharge" is in EFGH then consider the amount value in EFGH_2, or if "Fuel Surcharge" is in IJKL then consider the amount value in IJKL_3, or if "Fuel Surcharge" is not in any of the following columns, then consider 0.
I have written the condition for the "Fuel Surcharge" column in tmap like,
row1.tracking_id_charge_description.equals("Fuel Surcharge")?Double.parseDouble(row1.tracking_id_charge_amount1)
row1.tracking_id_charge_description1.equals("Fuel Surcharge")?Double.parseDouble(row1.tracking_id_charge_amount2)
row1.tracking_id_charge_description2.equals("Fuel Surcharge")?Double.parseDouble(row1.tracking_id_charge_amount3):"0"))))))))))))))))))))))))
Here, Description columns has datatype String and Amount columns has datatype Double. I have written the above function for new column "Fuel Surcharge" which has a datatype Double.
When I Execute, I get this Error: Type mismatch: cannot convert from Object&Comparable<?>&Serializable to Double
Please Help
Regards,
Swathi
I have 25 columns and have a requirement where in we need to search for a value in every column. Like if "Fuel Surcharge" is in ABCD then consider the amount value from the column ABCD_1, or if "Fuel Surcharge" is in EFGH then consider the amount value in EFGH_2, or if "Fuel Surcharge" is in IJKL then consider the amount value in IJKL_3, or if "Fuel Surcharge" is not in any of the following columns, then consider 0.
I have written the condition for the "Fuel Surcharge" column in tmap like,
row1.tracking_id_charge_description.equals("Fuel Surcharge")?Double.parseDouble(row1.tracking_id_charge_amount1)
Here, Description columns has datatype String and Amount columns has datatype Double. I have written the above function for new column "Fuel Surcharge" which has a datatype Double.
When I Execute, I get this Error: Type mismatch: cannot convert from Object&Comparable<?>&Serializable to Double
Please Help
Regards,
Swathi
957 Views
2 Replies

Anonymous
Not applicable
‎2012-05-04
03:52 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Swathi
I still remember we talked about this issue at 23342.
I think the most convenient way is not converting datatype in this expression.
Just choose String datatype in tMap. Then link it with tConvertType to change it from String to Double.
Your expression above is wrong. Because "0" is String. Double.parseDouble(row1.tracking_id_charge_amount3) is Double.
There are two datatypes in the same column.
Regards,
Pedro
I still remember we talked about this issue at 23342.
I think the most convenient way is not converting datatype in this expression.
Just choose String datatype in tMap. Then link it with tConvertType to change it from String to Double.
Your expression above is wrong. Because "0" is String. Double.parseDouble(row1.tracking_id_charge_amount3) is Double.
There are two datatypes in the same column.
Regards,
Pedro
957 Views

Anonymous
Not applicable
‎2012-05-04
04:00 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Pedro,
Yes I have written that function with your help. I want the column to be double, because that column need to be used to create a metric. Thanks a lot again, will use tConvertType
Regards,
Swathi
Yes I have written that function with your help. I want the column to be double, because that column need to be used to create a metric. Thanks a lot again, will use tConvertType
Regards,
Swathi
957 Views
