parse int to date (tmap ) Talend postgresql

Six Stars

parse int to date (tmap ) Talend postgresql

Hey all , My job Talend is about mapping between a csv file and a postregresql table. I need to insert a column date wich can be with normale format yyyyMMdd or(0/99999999) in the csv file.So if the date is equal to 0 or 99999999 it's will be mapping as a null variable in the database ,else the data must be loaded as a date type timestamp yyyy-mm-dd HH:mm:ss.

In the csv file i declared the date as an int , so i must parse int to a datetime in the tmap and loaded the 0/99999999 as a null variable . Any help please .


Accepted Solutions
Employee

Re: parse int to date (tmap ) Talend postgresql

@AsmaElsa 

 

Please refer the below flow for the solution.

image.png

 

image.png

 

image.png

 

Please note that while reading the csv, select String as the data type for input data (even if the data is integer). The function to be used is as below.

 

Relational.ISNULL(row1.input)|| row1.input.equalsIgnoreCase("99999999") || row1.input.equalsIgnoreCase("0")? null:TalendDate.parseDate("yyyymmdd",row1.input) 

Since your input value do not have time part, it will be automatically added as default values while checking from DB.

 

Hope I have answered your query. Please spare a second to mark the topic as resolved :-)

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

 

View solution in original post


All Replies
Five Stars

Re: parse int to date (tmap ) Talend postgresql

you can use tMap and Var (for ex. Var.datetime)

(rowX.i == 0 || rowX.i == 99999999 ) ? null: TalendDate.parseDate("yyyyMMdd", Integer.toString(i))

rowX is a input row,
Var.datetime must be inserted to output row.

Tags (1)
Employee

Re: parse int to date (tmap ) Talend postgresql

@AsmaElsa 

 

Please refer the below flow for the solution.

image.png

 

image.png

 

image.png

 

Please note that while reading the csv, select String as the data type for input data (even if the data is integer). The function to be used is as below.

 

Relational.ISNULL(row1.input)|| row1.input.equalsIgnoreCase("99999999") || row1.input.equalsIgnoreCase("0")? null:TalendDate.parseDate("yyyymmdd",row1.input) 

Since your input value do not have time part, it will be automatically added as default values while checking from DB.

 

Hope I have answered your query. Please spare a second to mark the topic as resolved :-)

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

 

View solution in original post

Six Stars

Re: parse int to date (tmap ) Talend postgresql

Thank you Smiley Happy 

2019 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch 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