Scenario : I have a requirement where I need to find the number of rows in the flat file and then compare the row count with the row count mentioned in the footer of the flat file.
Solution :
Using Infomratica:
I believe you can identify the data records from the trailer record. you
can use following method to identify the count of the records
1. use router to create two data streams ; one for data records & other for trailer record
2. use aggregator (with out defining any group key) and use count() aggregate function
now both data stream will have single record.
3.use joiner to get one record from these two data streams
it will give you two different count ports in single record
4. use expression for comparing the counts and proceed as per you rules.
1. use router to create two data streams ; one for data records & other for trailer record
2. use aggregator (with out defining any group key) and use count() aggregate function
now both data stream will have single record.
3.use joiner to get one record from these two data streams
it will give you two different count ports in single record
4. use expression for comparing the counts and proceed as per you rules.
Using UNIX :
If you are on Unix, then go for a couple of line script or commands:
Count number of lines in file by wc -l. Assign the count to variable x = (wc -l) - 1 i.e. neglecting footer record.
Grep the number of records from footer using grep/sed. Assign it to variable y.
Now equate both these variables and take decision.
Count number of lines in file by wc -l. Assign the count to variable x = (wc -l) - 1 i.e. neglecting footer record.
Grep the number of records from footer using grep/sed. Assign it to variable y.
Now equate both these variables and take decision.
Comments
Post a Comment