Hi,
I have got a requirement for which i need your help. The following problem is required to get solved in PERL SCRIPT. Here is the requirement.
There are 4 folders say SRC_DIR1, SRC_DIR2 and TGT_DIR_1,TGT_DIR_2
(Note: both path of SRC_DIR1 & SRC_DIR2 are different but both path of TGT_DIR1 & TGT_DIR2 are same but folder name is TGT_DIR1 & TGT_DIR2)
Say the files in folder SRC_DIR1 is as fololws :
aab_TRADE_20130226110444.csv
i.aab_20130226110444.csv
price.aab_20130226110444.csv
aab.i_20130226110444.csv
aab_price_aab_20130226110444.csv
Say the files in folder SRC_DIR2 is as follows :
aab_TRADE_20130226110444_PROCESSED.csv
i.aab_20130226110444_PROCESSED.csv
price.aab_20130226110444_PROCESSED.csv
aab.i_20130226110444_PROCESSED.csv
aab_price_aab_20130226110444_PROCESSED.csv
Now, each file present in folder SRC_DIR1 is compared with the folder SRC_DIR2 based on the following conditions :
CONDITION 1:
If any files in folder SRC_DIR1 whose first 20 characters is same as those in SRC_DIR2 and those 20 characters have has something like 'trade' as part of the filename then those files are to taken from SRC_DIR1 and moved to TGT_DIR1 and files in SRC_DIR2 to be moved to TGT_DIR2
OR
CONDITION 2:
If any files in folder SRC_DIR1 whose first 20 characters match with those in SRC_DIR2 and first 2 character of those 20 characters have the filename something like 'i.' as part of the filename then those files are to taken from SRC_DIR1 and moved to TGT_DIR1 and files in SRC_DIR2 to be moved to TGT_DIR2.
OR
CONDITION 3
If any files in folder SRC_DIR1 whose first 20 characters match with those in SRC_DIR2 and first 6 character of those 20 characters have the filename something like 'price.' as part of the filename then those files are to taken from SRC_DIR1 and moved to TGT_DIR1 and files in SRC_DIR2 to be moved to TGT_DIR2.
Now, there will be files in folder TGT_DIR1 and TGT_DIR2.
Files which satisfy condition 1 :
Lastly after getting the files in TGT_DIR1, the file content (present after 2nd comma and before 3rd comma has to be extracted and append a string like 'ABC,' before the extracted value. The new file name given can be said as SOURCE_FILE.csv. File present in TGT_DIR2 need not to be altered.
Files which satisfy condition 2 :
Lastly after getting the files in TGT_DIR1, the file content (present after 4th comma and before 5th comma has to be extracted and append a string like 'XYZ,' before the extracted value. All this records satisfying the condition 2 file naming convention should be appended to the above file name said as SOURCE_FILE.csv.
Files which satisfy condition 3:
Lastly after getting the files in TGT_DIR1, the file content (present after 7th comma and before 8th comma has to be extracted and append a string like 'MNO,' before the extracted value. All this records satisfying the condition 3 file naming convention should be appended to the above file name said as SOURCE_FILE.csv.
Finally the SOURCE_FILE.csv isto be created into a new path whose folder name is say TGT_DIR (for path of TGT_DIR is not as same as TGT_DIR1 & TGT_DIR2)
Can any body say how to approach this using PERL SCRIPT. Since I am from DWH background and have not worked on PERL Script any help is highly required.