|Problems? Is your data what you think it is?|
Parse values from multiple files into oneby hiradhu (Acolyte)
|on Nov 10, 2008 at 06:55 UTC||Need Help??|
hiradhu has asked for the wisdom of the Perl Monks concerning the following question:
I need ur help in solving this stuff. My req is ...
1. I have files SU1, SU2 ...like that . But the total number of files is unknown...there might be 7 or 6 files....
2. Similarly i have MU files -> MU1, MU2 etc...
3. These are tab delimited content. Each tab has Numbers..Sample format is:
4. Now I have to collect only the 2nd column from each file and put under output file
5. Output header is:
My approach is:
1. Read the contents and parse the 2column ..save it in Array..named @SU1 etc..
2. Then in a for loop ...print the rows in to a file
The output will be
1. Here the arrays SU_first etc are hardcoded. Ie I have restricted to only 3 arrays. If there are SU4 etc I cant use this script How to give a Dynamic name for array and retrieve it..?2. Or any other better approach?!!!
Finally from n number of tab limited files take only the 2nd column, find the average of each row and print it in another file.Pls help me. Thanks in advance!
(Original content above, restored by Arunbear. Updated content follows:)Hi Thanks for the response..But I'm not able tomend it as per my req..(I need some more expertise in PERL) here is what I need..
so @su1 will have 6,7,2 @su2 will have 60,70,20 etc..But I dont know how many such files in mu and su..there might be Su9, su10 etc. Runtime I need to check the number of files, get those values and print to one single file. Once I parse the values from each file, i have to print the values in columnwise. I think the solution given by you does an average (some calculation) of all su values in column 1 .. Can u pls help me. ?? Now I have hard coded the number of files to only 3 in my code.