Reputation: 2025
I have .csv
file which has column called created_ts
, and contains date values. However, date is written in two formats:
yyyy-MM-dd hh:mm:ss.SSSSSSX
)yyyy-MM-dd hh:mm:ssX
)So my problem is how to read data from .csv
file without getting error "Unparseable date: 2008-10-25 18:22:32+02"
Here's the picture showing how I put date format, but for created_ts
column I have date written in two different formats, so if I put first one, I get "Unparseable date: xxxxxx" error, and same error if I put second format....
Upvotes: 0
Views: 1159
Reputation: 4051
Since your dates can be of different formats, you need to read your column as a String type in your tFileInputDelimited
, then inside a tMap
, check the date type (a simple way to check it is by testing its length) and parse it using the correct date format:
tFileInputDelimited -- tMap -- output
In a tMap expression, you can have something like this :
row.created_ts.length() == 22 ? TalendDate.parseDate("yyyy-MM-dd hh:mm:ssX", row.created_ts) : TalendDate.parseDate("yyyy-MM-dd hh:mm:ss.SSSSSSX", row.created_ts)
Upvotes: 2