Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I'm trying to convert integer column to string getting "java. lang.NumberFormatException: For input string:"
my input integer column is as follows
1234
4467
4646
opt:
1234
4467
4646
I tried with Integer.toString(row1.emp_num) it throwing Number format exception.
Any suggestions would be helpful
Thanks and Regards,
Talend_ent.
The input column contains leading spaces.
Hi, have you tried String.valueOf(row1.emp_num) ?
Send me Love and kudos
@guenneguez jeremy yes, I tried with String.ValueOf() getting same error.
with wich component do you read data ?
what is your data source (csv ,database,xml...)?
are you succeed in reading it as number ?
if it's csv for example just change the type of your column in the schema to string in tfileinputdelimited component
@guenneguez jeremy my source is xml and I changed the datatype as a string it is working fine .
when I using datatype converstion in tMap getting null pointer exception here is my tmap expression
row1.emp_num.equals(null)||row1.emp_num==null?null:Integer.parseInt(row1.emp_num.trim());
any workaround.
(row1.emp_num!=null && !row1.emp_num.equals("null"))?Integer.parseInt(row1.emp_num.trim()):null
or
(row1.emp_num!=null && !(row1.emp_num.replaceAll("\\D")).equals("") )?Integer.parseInt(row1.emp_num.trim()):null
for the second one i test null value then i look if when i delete all non digit char there is an empty value or not
For the first expression it throwing null pointer exception. coming to the second one in replaceall method you're using single argument instead of two.
attachment shows the error for second expression.
sorry my fault :
(row1.emp_num!=null && !(row1.emp_num.replaceAll("\\D","")).equals("") )?Integer.parseInt(row1.emp_num.trim()):null
Again i'm getting java.lang.NullPointerException.