Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello All,
My requirement is to load data from excel to sql server table.
Im suppose to validate my data in tmap to check for null values:
here are the my validations sample :
1. Integer (source and target) integer type. -> (row1.XXAPID == null)? null:row1.XXAPID
2. for Date type .-> row1.INVOICE_DATE.equals("null")?null:TalendDate.parseDate("MM-dd-yyyy HH:mm:ss",row1.INVOICE_DATE) and checked with TalendDate.formateDate also.
3. string to string type-> (row1.LINE_TYPE_LOOKUP_CODE.equals("null")? null :row1.LINE_TYPE_LOOKUP_CODE
4. float to float type --> (row1.DIST_ITEM_AMOUNT ==null) ? null : row1.DIST_ITEM_AMOUNT.floatValue()
I'm facing the following error while running my job
Can any one please help me to resolve this.
It's very emergency.
In excel file for all the data types like string, integer, float, big decimal,date has both null string and some data .
for example:
in source file:
col1 col2 col2
a 12.3 05/23/2016
null null null
b null null
expected output: sql server table
col1 col2 col2
a 12.3 05/23/2016
null null null
b null null
I really don't know to use this java inbuilt convert types like
Integer.parseInt(),Float.parseFloat() in my expression builder
I hope you understood my requirements!
If you don't mind can you send me some demo to load data with integer, float, date, string, bigdecimal type?
You can refer to this Screenshot,
These are the conversions happening,
Col1 : string to integer
Col2 : string to float
Col3 : string to date
Col4 : string to string
Col5 : string to bigdecimal
Be careful though. Here I am assuming that your input data matches the datatypes. If it doesn't then the job will fail.
So you have to make sure that you filter out the values which are invalid before converting them.
Hi,
Thank you so much for your guidance.
here I have attached the error while I'm trying this validation method
TalendDate.parseDate("dd/MM/yyyy",row1.ExcelDateCol)
(row1.ExcelDateCol!=null)?TalendDate.parseDate("dd/MM/yyyy",row1.ExcelDateCol):null
facing the following error:
[statistics] connecting to socket on port 3901
[statistics] connected
Exception in component tMap_1
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "Mon Nov 04 00:00:00 IST 2013"
at routines.TalendDate.parseDate(TalendDate.java:895)
at routines.TalendDate.parseDate(TalendDate.java:839)
at newproject.stellarexcel_tbl_0_1.Stellarexcel_tbl.tFileInputExcel_1Process(Stellarexcel_tbl.java:3899)
at newproject.stellarexcel_tbl_0_1.Stellarexcel_tbl.runJobInTOS(Stellarexcel_tbl.java:4690)
at newproject.stellarexcel_tbl_0_1.Stellarexcel_tbl.main(Stellarexcel_tbl.java:4547)
Caused by: java.text.ParseException: Unparseable date: "Mon Nov 04 00:00:00 IST 2013"
at java.text.DateFormat.parse(Unknown Source)
at routines.TalendDate.parseDate(TalendDate.java:881)
The format that you are using to parse the date should match the incoming value.
In your case the format should be "EEE MMM dd HH:mm:ss 'IST' yyyy" instead of "dd/MM/yyyy".
Also you should mention the same format as the output column date pattern.
If I use this format for validation then what about the other date which is also present in the same column.
I guess we are almost done.
My question is can we write expression with AND operator to check for all the date formats from the file other than checking only null?