
Creator III
2011-04-01
11:47 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[resolved] Tmap - String to Int - And return null if null
This will convert a string to an integer:
Integer.parseInt(row1.value1)
How can I change this to work for converting a String to Int and return null there is no value?
(row1.value1==null)?null:TalendDate.parseDate("dd/MM/yyyy", row1.value1)
Is this close?
(row1.value1==null)?null:Integer.parseInt(row1.value1)
Integer.parseInt(row1.value1)
How can I change this to work for converting a String to Int and return null there is no value?
(row1.value1==null)?null:TalendDate.parseDate("dd/MM/yyyy", row1.value1)
Is this close?
(row1.value1==null)?null:Integer.parseInt(row1.value1)
2,755 Views
1 Solution
Accepted Solutions

Specialist III
2011-04-05
02:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
do it like this
(row1.value1==null || row1.value1=="" )?null:Integer.parseInt(row1.value1)
or you can use
(row1.value1.length >0 )?null:Integer.parseInt(row1.value1)
Regards
Vijay.M
do it like this
(row1.value1==null || row1.value1=="" )?null:Integer.parseInt(row1.value1)
or you can use
(row1.value1.length >0 )?null:Integer.parseInt(row1.value1)
Regards
Vijay.M
2,755 Views
5 Replies

Anonymous
Not applicable
2011-04-02
12:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Yes, you are right. let us know if you don't get the expected result.
Best regards
Shong
Is this close?
(row1.value1==null)?null:Integer.parseInt(row1.value1)
Yes, you are right. let us know if you don't get the expected result.
Best regards
Shong
2,755 Views

Creator III
2011-04-04
02:51 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I get this error:
Exception in component tMap_1
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at talenddemosjava.myJob_0_1.myJob.tFileInputDelimited_1Process(myJob.java:1171)
at talenddemosjava.myJob_0_1.myJob.runJobInTOS(myJob.java:1682)
at talenddemosjava.myJob_0_1.myJob.main(myJob.java:1556)
Exception in component tMap_1
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at talenddemosjava.myJob_0_1.myJob.tFileInputDelimited_1Process(myJob.java:1171)
at talenddemosjava.myJob_0_1.myJob.runJobInTOS(myJob.java:1682)
at talenddemosjava.myJob_0_1.myJob.main(myJob.java:1556)
2,755 Views

Specialist III
2011-04-05
02:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
do it like this
(row1.value1==null || row1.value1=="" )?null:Integer.parseInt(row1.value1)
or you can use
(row1.value1.length >0 )?null:Integer.parseInt(row1.value1)
Regards
Vijay.M
do it like this
(row1.value1==null || row1.value1=="" )?null:Integer.parseInt(row1.value1)
or you can use
(row1.value1.length >0 )?null:Integer.parseInt(row1.value1)
Regards
Vijay.M
2,756 Views

Creator III
2011-04-06
04:03 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks mailforvijaym & shong,
I found out that my data had several bad records with less than the correct number of delimiters.
I found out that my data had several bad records with less than the correct number of delimiters.
2,755 Views

Anonymous
Not applicable
2014-07-04
08:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Shong,
I would appreciate it if you could tell me what is the Talend best practice for the following scenario:
I receive input as an XML document and use tXMLMap to split the fields (Which are all string) but some of them are supposed to be inserted into the database as decimal and some as int. So shall I do the converting of strings to BigDecimal and int within tXMLMap and then check if the required fields have been filled in at tFilterRow or shall I do both converting and checking in tFilterRow?
Also, the filtering code is quite long in tFilterRow so shall I create routines and call them - any advice on this will be greatly appreciated.
Best regards,
Shujel
I would appreciate it if you could tell me what is the Talend best practice for the following scenario:
I receive input as an XML document and use tXMLMap to split the fields (Which are all string) but some of them are supposed to be inserted into the database as decimal and some as int. So shall I do the converting of strings to BigDecimal and int within tXMLMap and then check if the required fields have been filled in at tFilterRow or shall I do both converting and checking in tFilterRow?
Also, the filtering code is quite long in tFilterRow so shall I create routines and call them - any advice on this will be greatly appreciated.
Best regards,
Shujel
2,755 Views
