logic to split dates in talend

Seven Stars

logic to split dates in talend

Hi All,

 

I have one requirement,my source has one date column as

date                     location

5-10 jan,14             x

 

i want my output as

date                 location

5-01-2014           x

6-01-2014           x

7-01-2014           x

8-01-2014           x

9-01-2014           x

10-01-2014          x

 

can we do this in talend.

please help me out

 

Thanks & regards

Rekha


Accepted Solutions
Community Manager

Re: logic to split dates in talend

Yes you can. First of all, how much Java do you know? This will need a little bit of Java (not difficult stuff) to isolate the month and year (Jan, 14) from the day range. You can use String methods for this (see here https://docs.oracle.com/javase/7/docs/api/java/lang/String.html). You will then need to work out your "from" and "to" days. Again, String manipulation will be useful here. 

Once you have your date and day range known, you can implement some functionality to create a list of days that make up that range. This can be done with a tMap and a tJavaFlex as the lookup. I have written a tutorial which shows the approach I would suggest, here (https://www.rilhia.com/quicktips/quick-tip-row-multiplication). For every row you get which has your date+range value, this method will multiply it by the number of days in that range. So if you have a row with a range of 5 days, it will convert that single row into 5 rows, each with a different date.

I have purposefully not given you the Java you will need because I think it makes sense for you to work it out from what I have told you. If you have Java already, that will be easy. If you don't have Java, then if you are going to continue with Talend you will need it :-)


All Replies
Community Manager

Re: logic to split dates in talend

Yes you can. First of all, how much Java do you know? This will need a little bit of Java (not difficult stuff) to isolate the month and year (Jan, 14) from the day range. You can use String methods for this (see here https://docs.oracle.com/javase/7/docs/api/java/lang/String.html). You will then need to work out your "from" and "to" days. Again, String manipulation will be useful here. 

Once you have your date and day range known, you can implement some functionality to create a list of days that make up that range. This can be done with a tMap and a tJavaFlex as the lookup. I have written a tutorial which shows the approach I would suggest, here (https://www.rilhia.com/quicktips/quick-tip-row-multiplication). For every row you get which has your date+range value, this method will multiply it by the number of days in that range. So if you have a row with a range of 5 days, it will convert that single row into 5 rows, each with a different date.

I have purposefully not given you the Java you will need because I think it makes sense for you to work it out from what I have told you. If you have Java already, that will be easy. If you don't have Java, then if you are going to continue with Talend you will need it :-)

Four Stars

Re: logic to split dates in talend

Hi Rekha,

Did you able to solve this one?? I am still struggling.

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch