Hi All
I have tab files. This is UAT result
System : AIX 5.3 gawk 3.1.3
Field[1] = Item code
Field[3] = Tester, User Name
Field[9] = testing result. Pass , Fail, TBA, WI , [other code],,, etc
Input File
A0 .. user1 .. Pass
A1 .. user1 .. Pass
A2 .. user2 .. Fail
A3 .. user1 .. TBA
A4 .. user3 .. WI
.....
Base on Field 1 , 3 , 9 report as below
Item = How many item tested by User
Order Placed By Item Pass Fail TBA WI [Other
Code] ..... Waiting Test Order
---------------- ---------- ----- ----- ----- -----
user1 3 2 0 1 0
user2 1 0 1 0 0
user3 1 0 0 0 1
......
I try multi Array, The result is not good. May be first time using
Multi Array is the good for me.
Also when using asort , What is wrong for below ?
k = asort(user)
for (i =1 ; i < k ; i++ ) {
e = user[i]
....
}
Any suggestion ?
My current code as below. This can not handle [other code]
user[$3]++
if ( tolower($9) ~ /pass/) {user_pass[$3]++}
if ( tolower($9) ~ /fail/) {user_fail[$3]++}
if ( tolower($9) ~ /tba/ ) {user_tba[$3]++}
if ( tolower($9) ~ /wi/ ) {user_wi[$3]++}
user_total[$3]++ # Total Item
END {
fmt01="%-20s %4s %4s %4s %4s %4s %10s\n"
printf(fmt01,"","","","","","","Waiting")
printf (fmt01, \
"Order Placed By","Item","Pass","Fail","TBA","WI","Test
Order")
printf (fmt01,rep("-",
20),"----","----","----","----","----",rep("-",10))
a1= 0 ; a2 = 0 ; a3=0 ; a4= 0 ; a5= 0 ; a6 = 0
#k = asort(user)
for ( e in user) {
# for (i =1 ; i < k ; i++ ) {
# e = user[i]
if ( e != "" ) {
a61 = user_total[e] - user_pass[e] - user_fail[e] -
user_tba[e] - user_wi[e]
printf(fmt01, \
e ,
user_total[e],user_pass[e],user_fail[e],user_tba[e],user_wi[e], a61)
a1 += user_total[e]
a2 += user_pass[e]
a3 += user_fail[e]
a4 += user_tba[e]
a5 += user_wi[e]
a6 += a61
}
}
}
function rep(s,n, t) {
while (n-- > 0 )
t = t s
return t
|
|
0
|
|
|
|
Reply
|
moonhkt (146)
|
3/10/2012 5:04:41 PM |
|
moonhkt <moonhkt@gmail.com> wrote:
> Hi All
>
> I have tab files. This is UAT result
>
> System : AIX 5.3 gawk 3.1.3
>
> Field[1] = Item code
> Field[3] = Tester, User Name
> Field[9] = testing result. Pass , Fail, TBA, WI , [other code],,, etc
>
>
> Input File
> A0 .. user1 .. Pass
> A1 .. user1 .. Pass
> A2 .. user2 .. Fail
> A3 .. user1 .. TBA
> A4 .. user3 .. WI
> .....
> Base on Field 1 , 3 , 9 report as below
>
> Item = How many item tested by User
>
> Order Placed By Item Pass Fail TBA WI [Other
> Code] ..... Waiting Test Order
> ---------------- ---------- ----- ----- ----- -----
> user1 3 2 0 1 0
> user2 1 0 1 0 0
> user3 1 0 0 0 1
> ......
>
> I try multi Array, The result is not good. May be first time using
> Multi Array is the good for me.
>
> Also when using asort , What is wrong for below ?
>
> k = asort(user)
>
> for (i =1 ; i < k ; i++ ) {
> e = user[i]
> ....
> }
>
> Any suggestion ?
>
> My current code as below. This can not handle [other code]
>
> user[$3]++
> if ( tolower($9) ~ /pass/) {user_pass[$3]++}
> if ( tolower($9) ~ /fail/) {user_fail[$3]++}
> if ( tolower($9) ~ /tba/ ) {user_tba[$3]++}
> if ( tolower($9) ~ /wi/ ) {user_wi[$3]++}
> user_total[$3]++ # Total Item
>
> END {
> fmt01="%-20s %4s %4s %4s %4s %4s %10s\n"
> printf(fmt01,"","","","","","","Waiting")
> printf (fmt01, \
> "Order Placed By","Item","Pass","Fail","TBA","WI","Test
> Order")
> printf (fmt01,rep("-",
> 20),"----","----","----","----","----",rep("-",10))
>
> a1= 0 ; a2 = 0 ; a3=0 ; a4= 0 ; a5= 0 ; a6 = 0
> #k = asort(user)
> for ( e in user) {
> # for (i =1 ; i < k ; i++ ) {
> # e = user[i]
> if ( e != "" ) {
> a61 = user_total[e] - user_pass[e] - user_fail[e] -
> user_tba[e] - user_wi[e]
> printf(fmt01, \
> e ,
> user_total[e],user_pass[e],user_fail[e],user_tba[e],user_wi[e], a61)
> a1 += user_total[e]
> a2 += user_pass[e]
> a3 += user_fail[e]
> a4 += user_tba[e]
> a5 += user_wi[e]
> a6 += a61
> }
> }
>
>
> }
>
> function rep(s,n, t) {
> while (n-- > 0 )
> t = t s
> return t
>
Anyone else feel kinda bad that this post presumably sparked the whole
"how do you sort multi-D arrays" discussion but it itself never got
addressed?
On the other hand, the OP could have taken a few minutes to write a small
script that just demonstrates their problem without all the extraneous
code and line-wrapping so we wouldn't have to work nearly so hard to
figure out what his question is, so I guess I don't feel too bad about it.
Ed.
Posted using www.webuse.net
|
|
0
|
|
|
|
Reply
|
mortonspam (827)
|
3/20/2012 2:28:45 PM
|
|
|
1 Replies
97 Views
(page loaded in 0.045 seconds)
Similiar Articles: Hierarchical data structure from a multi-dimensional array - comp ...Hi all, I would appreciate any help. I have a multi-dimensional array representing the column and row dimensions in a table and values in the t... Unpacking a cell array into multiple variables - comp.soft-sys ...Hi! I have an MxN cell array, C, I'd like to unpack--using assignment syntax and without explicit looping--into N variables, i.e., I'd like to do som... use macro to import multiple excel files? - comp.soft-sys.sas ...how can i use macro to import multiple excel files? I cannot define array inside the macro, so I use data _NULL_, but it doesn't work. Also I try to... Convert multi dimentional array to array of hashes - comp.lang ...I have a multi-dimensional array representing the column and row ... Splitting into a multi-dimensional array - comp.lang ... to convert a cell array ... array data ... awk challenge: sort array using only for ... in ... - comp.lang ...... if (a[i]>=a[maxin]) maxin=i # note the >= is important if there are multiple ... because it has room for only as many ... sorts the lines by making an array using the ... Index over multiple cell arrays with cellfun - comp.soft-sys ...Is it possible to index over multiple cell arrays with cellfun? For example, I have two cell arrays of the same size C and D. I would like perform a... vec(.) operator for multidimensional array - comp.soft-sys.matlab ...help needed for a grep in a multidimensional struct array - comp ... Convert multi dimentional array to array of hashes - comp.lang ... vec(.) operator for ... Find minimum value in array - comp.soft-sys.matlabI need to find the minimum value in an array and return an array [m n] where m is the smallest number and where n is the position in the array. I need... max and min of multiple cell arrays - comp.soft-sys.matlab ...max and min of multiple cell arrays - comp.soft-sys.matlab ... hello guys, Below is my ... Cell Boundary Detection - comp.soft-sys.matlab I would use a cell array: nlabel ... Performance: struct vs. cell array - comp.soft-sys.matlab ...One is to use cell arrays: a = {... [ 1 2 3 4], ... [0], ... [55555 4444 333 22 ... performance array of struct vs. multiple arrays - comp.soft-sys ... Access multiple ... Using Arrays (C++) - Microsoft Corporation: Software, Smartphones ...In the preceding code, multi is a three-dimensional array of type double. The p2multi pointer points to an array of type double of size three. The array is used with ... Multiple Dimensional Arrays - JavaScript Tutorials and ScriptsHandling multiple dimensional arrays in Javascript. ... One of the advantages of this approach using arrays of arrays ... 7/22/2012 5:24:18 PM
|