Talend adding extra zeros values for string columns

Seven Stars RAJ
Seven Stars

Talend adding extra zeros values for string columns

Hi Talend Folks,

 

 Am face issue while generate data source to destination for string column. Before adding extra zeros for that column values in talend output excel file. My source file is excel and output file is also excel.
I need same input format values to output
My input is below format 
4567567
4536785
4567890
45678905678-01
45675458765-02
 
I got this format value
0000000456756
0000000453678
0000000456789
45678905678-01
45675458765-02
Kindly share your information as soon as possible.
Thanks
RAJ
Employee

Re: Talend adding extra zeros values for string columns

Hi,

 

Talend will not add extra zeros at the front, without some specific logic somewhere.  Are you sure your target Excel file does not have a column format defined that is showing these extra zeros? 

Unless you have specified a format in the schema definition, or somewhere in your job, or your target Excel has a format defined on the column, I don't where this will be coming from.

 

Irshad

Thirteen Stars

Re: Talend adding extra zeros values for string columns

@RAJ,your excel file might have leading zeros format.

Manohar B
Forteen Stars TRF
Forteen Stars

Re: Talend adding extra zeros values for string columns

Using a tJavaRow you can do that:

output_row.yourField = 
  input_row.yourField != null && input_row.yourField.length() == 14 ? 
      input_row.yourField : 
("00000000000000"+input_row.yourField).substring(("00000000000000"+input_row.yourField).length() - 14);

Here is the result:

Démarrage du job test a 10:02 31/05/2018.
[statistics] connecting to socket on port 3847
[statistics] connected
00000004567567
00000004536785
00000004567890
45678905678-01
45675458765-02
[statistics] disconnected
Job test terminé à 10:02 31/05/2018. [Code sortie=0]

 

 


TRF
Forteen Stars TRF
Forteen Stars

Re: Talend adding extra zeros values for string columns

@RAJ, I read you case too fast and thought you want to add leading zeros.

Then I try to push your sample content to an Excel file (field field defined as String) and it works fine, no leading zeros in the output file.

 


TRF