multiple file reading

2005-11-23 11:48:47 PM
I am quite confused of how to do this:
I have 3 set of files:
1- One file (e.g. Source.txt) has 5 columns x 365 rows (weather data
actually) (data: Real)
2-30 (years) files (1.txt, 2.txt, 3.txt.....30.txt) again each one has 5
columns x 365 rows (data: Real)
3-one output file (outfile.txt).
I need to read the data in row 59 (BEG_day=59) of (source.txt) (e.g.
a1=day=59, a2,a3,a4,a5) then :
I should read the data (a2,a3,a4,a5) of all 30 (years) files from + and - 7
days of 59 excluding the row (or day) 59 in other words I should read those
a2,a3,a4,a5 of days 52, 53, 54, 55, 56, 57,58, 60,61,62,63,64,65,66 (of year
1.txt, then 2.txt then 3.txt till 30.txt) now
I need to calculate:
D_52:= sqrt ((a2(59, source file)-a2(52,ref file))^2) + ((a3(59, source
file)-a3(52,ref file))^2)+ ((a4(59, source file)-a4(52,ref
file))^2)+((a3(59, source file)-a3(52,ref file))^2)
Then do next: change the day from 52 to 53 and 54...till 66. for each year
Finally here I have 14 x 30 data (D_1 to D14x30)
Now lets say I choose day 55(randomly) of year 27 (27.txt) based on D_55. At
this stage I need to copy and paste the a2,a3,a4,a5 of day 55 of year 27
(27.txt) and then save them as first row of output file (outfile.txt).
Now I should loop back again:
Beg_day:=BEG_Day+1 (59+1=60)
I should do the whole process (above) again and again till BEG_Day :=END_Day
I will DO appreciate any help on this.