How to compare the input file first row value with the all rows in the second input file column in talend
Solved! Go to Solution.
For this scenario you need to Iterate 1-Input File and Compare this value with the another input Flow.
In First flow take tFileInputDelimitted , tFlowToIterate , then connect iterate to tMap component. In Second flow take another tFileInputDelimitted component and lookup this to tMap Component. In join Condition perform a Join operation.
Hi Thank you so much fo ryour quick reply on this , but i cannot able to connect the tFlowToIterate , then connect iterate to tMap component.
Please help.Actually my task is
i have a input file with date column having different formats which is unknow to the user in which format is and another file is having all possible different date formats. i need to compare the inpute date with all possble date formats in the another file .
for that am using the logic TalendDate.isDate(row1.line,row2.date)?TalendDate.parseDate(row2.date,row1.line):
where row1.line is my input date row2.date is my date format in the another file.if matches then parse the string date . to sample date format.
would you please tell the Job flow
It would be great if you can provide me some sample data, So that I can explain you perfectly. If am not wrong you wants to check whether the Incoming date_format is a valid date format or not by comparing this with some predefined date_formats. Otherwise you need to reject the record.
Yes it is same u expected.but
I am attaching the input_date file and date _pattern file please provde me the flow
What are you trying to do here?
Are you validating input date value is in any of specified for or not?
Its working fine.Thank you but how would i catch the input date that does not matched in the datepattern file.Not matched with date patterns in file .i would like to catch that date in outputfile.Any suggestion on this.
i tried in this way but not bale to catch the not matched date date
If you want the non-matching date elements as well, just remove the filter condition in the 2nd tMap which @vboppudi has provided then all the records will be available with boolean flag (true/false). You can easily identify the non-matched date patterns.
Thank you for your reply. but I am not clear Mr.skh can u please eloborate what you said.Actually the job i did in the above screen shot is i will check the input date with all date patterns in the date pattern file(look up file) if pattern found then the date is parsed to one defined format other wise null
i am outputting the data which the Var.var1 is not null means only parsed dates only i output to the logrow. but i want the dates that are not matched with any of the date_pattern in the file.actually as per my job.. what the job is doing if input sting date pattern is matched wiht any of the predefinrd pattens the parsing the string to date format. if false it will out put all not matched dates.means for every input string compared date patterns not matched ...all rows willl be given as ouput .but i want the dates which or not that patter found in the file.
can i get any solution on this.
You wants to separate both valid and in-valid dates right ..? Just you need to add a filter condition in the tMap_2 and separate both the flows to different output files (here I diverted both of them in tLogRow Components you can replace them with suitable output components.)
As we know that bolean stands for either true or false. So if we keep this bolean column in the tMap filter condition it will filter the records based on the true condition.
a1.Flag - (as it defined as bolean) so all the valid records will route through this pipeline.
!a1.Flag- Unvalid i.e, which doesn't match the condition will route through this flow.
Hope this helped you.
sry sir this is not working.sir this will be printing the all dates as the input date from one file compares the all predefined patterns if not matching printing that date that many times.the inputdate is iterating through all patterns so if first pattern not match date is printins as not matched second is compared matched it will not.
but my scenarion is different if the inpute date is not matched with any of the predefined patterns in the other file(loopup file).the date should display as not parsed.
Hi Hameed sir
I checked the screen shots u shared but that is getting 73 rows as output for not matching .but we have only 13 rows input
we have 13 input string if any of that string does not have pattern matched in the predefined date pattern file that date should display in another outputfile..so that we can come to know which dates are not been parsed to one defined format.
Am new to this talend am learning now .so that the reason am not able to solving it quickly.
Hello sir ,
Can you please tell how to get the dates which are not parsed. ie the input string daes not have that predefined pattern in the date_pattern file .the date should be output as rejected.
possible please share the job n screen shots....Very much thank ful the one to which you replied..
Thank you so much sir ....
it helps .I will try it actually i tried the same but i didn't use the tunique row.where as it is populating all input dates in invalid dates file.the screen shot you shared the out .in tat also the dates which are in the valid output also there in the invalid output. how could that possible?.it should not come in invalid dates output. sir would u please check on the same..
Here also exists a tFileCompare component which compares two files and provides comparison data based on a read-only schema.
For more information, please refer to online document about:TalendHelpCenter:tFileCompare.
Hi Veeranjaneyulu garu,
can i have update on this sir..what i was facing issue with this.
this is giving all dates as rejected.
The following problem is not solved!
Do you have any Idea how to catch the unparsed dates to the output.
The job i provided has two targets one for valid dates and another one for invalid dates.
in tMap, you have two create two output groups one for valid dates and another one for invalid dates. For valid dates it will return only matched pasterns. For invalid output it will return all not matched patterns. So use tUniq after tamp for invalid output.
You can redirect the standard out to a file for the entire Job run by using tJava component.
And please use the following code
java.io.File file = new java.io.File("C:/temp/mytalend.log"); java.io.PrintStream log_java = new java.io.PrintStream(new java.io.FileOutputStream(file)); System.setOut(log_java);
Let us know if it works