Project scenarios

Highlighted
Six Stars

Project scenarios

a.PNG

 

Scenario 1 :

I have to insert comma in the values.

ex: 32825 o/p : 32,825

3281564 o/p : 3,281,564 

Before third digit i have to place comma.

 

Scenario 2 :

I have to replace the values -7.8 to (7.8)

need to replace open and close brackets for minus values.


Accepted Solutions
Highlighted
Six Stars

Re: Project scenarios

It worked after changing into this.

 

row11.EBITDA_MARGIN_Dec_17 .contains("-")?"("+row11.EBITDA_MARGIN_Dec_17 .replace("-","")+")": row11.EBITDA_MARGIN_Dec_17; 

View solution in original post


All Replies
Highlighted
Moderator

Re: Project scenarios

@Darmesh,

1:- if you were using tFileOutputExcel using to populate data,for the number filed you can specify Thousands separator.

 

Untitled.png

2:- you can use the below one.

!row1.filed.equals("") || row1.filed!=null||row1.filed.contains("-")>0?"("+row1.filed.replace("-","")+")": row1.filed

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Highlighted
Six Stars

Re: Project scenarios

@manodwhb

for scenario2 . am getting below error

 

a.PNGb.PNG

Highlighted
Six Stars

Re: Project scenarios

It worked after changing into this.

 

row11.EBITDA_MARGIN_Dec_17 .contains("-")?"("+row11.EBITDA_MARGIN_Dec_17 .replace("-","")+")": row11.EBITDA_MARGIN_Dec_17; 

View solution in original post

Highlighted
Moderator

Re: Project scenarios

try this

!row1.filed.equals("") || row1.filed!=null||row1.filed.contains("-")?"("+row1.filed.replace("-","")+")": row1.filed

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Highlighted
Six Stars

Re: Project scenarios

@manodwhb

It is working fine. But sometimes column will contain null values. so how to overcome null pointer exception.

Highlighted
Six Stars

Re: Project scenarios

@manodwhb @TRF @rhall_2_0

 

It is working fine. But sometimes column will contain null values. so how to overcome null pointer exception.

Highlighted
Moderator

Re: Project scenarios

Try the below one.

!row1.filed.equals("") || row1.filed!=null||row1.filed.contains("-")?"(row1.field==null?row1.fieldSmiley Sad"+row1.filed.replace("-","")+")"): row1.filed
Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Highlighted
Six Stars

Re: Project scenarios

Error after using the below code

 

String literal is not properly closed by a double-quote

 

!row1.filed.equals("") || row1.filed!=null||row1.filed.contains("-")?"(row1.field==null?row1.field"+row1.filed.replace("-","")+")"): row1.filed

Highlighted
Moderator

Re: Project scenarios

try the below one.

 

!row1.filed.equals("") || row1.filed!=null||row1.filed.contains("-")?(row1.field==null?row1.field:"("+row1.filed.replace("-","")+")"): row1.filed

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Highlighted
Six Stars

Re: Project scenarios

it has null values.

 

error :

 java.lang.NullPointerException

Highlighted
Moderator

Re: Project scenarios

this should fix for the null pointer exception row1.filed

 

if you still gets you have look for other columns may be causing null pointer exception.

 

 

!row1.filed.equals("") || row1.filed!=null||row1.filed.contains("-")?"("+row1.filed.replace("-","")+")": row1.filed

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Highlighted
Six Stars

Re: Project scenarios

still the same error.

But i want to load the null values into the excel without getting null exception error.

a.PNG

OR

Is there any other method to convert negative values to () brackets.

Highlighted
Moderator

Re: Project scenarios

@Darmesh, i am able to get with below expresion. please check

 

(!row3.newColumn1.equals("") || row3.newColumn1!=null) &&row3.newColumn1.contains("-")?"("+row3.newColumn1.replace("-","")+")": row3.newColumn1 

 

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog