S
shree
Hi,
I have been asked to transpose a data file extracted from an Excel
report and saved as a .txt file. It lists time (MonthYear) in the
header (first row). The data consists of blocks of 3 lines per
supplier. In the example extract shown below, for Jan-04, total items
supplied by supplier 1 were 1000, of which there were 200 defects,
giving a defect ratio of 20%. I need to read-in this data file and
output a file whose format I can best illustrate via an example shown
below. Please note in the outfile's last column, it shows MonthID. If
the data were to begin with Feb-04 and go till July-04, instead of
Jan-04 to Mar-04 as shown below, then Feb-04 would be 1, Mar-04 2 and
so on.
Anyway, I'm struggling on thoughts of how to build a data structure to
transform the data into the desired output file. Any pointers, code
snippets will be greatly appreciated and I thank you in advance.
Best wishes,
Shree
Sample Data filein.dat
Jan-04 Feb-04 Mar-04
Supp1 % 20.00% 10.17% 7.14%
Defects 200 122 100
Total 1000 1200 1400
Supp2 % 3.00% 1.82% 1.90%
Defects 60 40 40
Total 2000 2200 2100
Desired Output fileout.txt
Supp1 % 20.00% Jan-04 1
Supp1 Defects 200 Jan-04 1
Supp1 Total 1000 Jan-04 1
Supp1 % 10.17% Feb-04 2
Supp1 Defects 122 Feb-04 2
Supp1 Total 1200 Feb-04 2
Supp1 % 7.14% Mar-04 3
Supp1 Defects 100 Mar-04 3
Supp1 Total 1400 Mar-04 3
Supp2 % 3.00% Jan-04 1
Supp2 Defects 60 Jan-04 1
Supp2 Total 2000 Jan-04 1
Supp2 % 1.82% Feb-04 2
Supp2 Defects 40 Feb-04 2
Supp2 Total 2200 Feb-04 2
Supp2 % 1.90% Mar-04 3
Supp2 Defects 40 Mar-04 3
Supp2 Total 2100 Mar-04 3
I have been asked to transpose a data file extracted from an Excel
report and saved as a .txt file. It lists time (MonthYear) in the
header (first row). The data consists of blocks of 3 lines per
supplier. In the example extract shown below, for Jan-04, total items
supplied by supplier 1 were 1000, of which there were 200 defects,
giving a defect ratio of 20%. I need to read-in this data file and
output a file whose format I can best illustrate via an example shown
below. Please note in the outfile's last column, it shows MonthID. If
the data were to begin with Feb-04 and go till July-04, instead of
Jan-04 to Mar-04 as shown below, then Feb-04 would be 1, Mar-04 2 and
so on.
Anyway, I'm struggling on thoughts of how to build a data structure to
transform the data into the desired output file. Any pointers, code
snippets will be greatly appreciated and I thank you in advance.
Best wishes,
Shree
Sample Data filein.dat
Jan-04 Feb-04 Mar-04
Supp1 % 20.00% 10.17% 7.14%
Defects 200 122 100
Total 1000 1200 1400
Supp2 % 3.00% 1.82% 1.90%
Defects 60 40 40
Total 2000 2200 2100
Desired Output fileout.txt
Supp1 % 20.00% Jan-04 1
Supp1 Defects 200 Jan-04 1
Supp1 Total 1000 Jan-04 1
Supp1 % 10.17% Feb-04 2
Supp1 Defects 122 Feb-04 2
Supp1 Total 1200 Feb-04 2
Supp1 % 7.14% Mar-04 3
Supp1 Defects 100 Mar-04 3
Supp1 Total 1400 Mar-04 3
Supp2 % 3.00% Jan-04 1
Supp2 Defects 60 Jan-04 1
Supp2 Total 2000 Jan-04 1
Supp2 % 1.82% Feb-04 2
Supp2 Defects 40 Feb-04 2
Supp2 Total 2200 Feb-04 2
Supp2 % 1.90% Mar-04 3
Supp2 Defects 40 Mar-04 3
Supp2 Total 2100 Mar-04 3