- 论坛徽章:
- 5
|
本帖最后由 pitonas 于 2014-11-01 06:13 编辑
是酱? {:2_168:}
- 忽略 key 的值是字符的单调性检查(vt 和 corner列)
- 忽略 t_clk_r_q_r
- 没检查重复行
beta gamma vt corner
matter 2 1 x y
alpha 3 3 6 8 9
value 0.2 0.3 0.1 0.2 0.1
trend 没有单调性
beta gamma vt corner
matter 2 2 x z
alpha 2 5 7
value 0.2 0.4 0.5
trend 单调增
beta gamma vt corner
matter 2 3 x y
alpha 9 10 11
value 0.7 0.5 0.3
trend 单调减
alpha gamma vt corner
matter 5 2 x z
beta 2
value 0.4
trend 只有这一个
......
alpha gamma vt corner
matter 3 1 x y
beta 2 2
value 0.2 0.3
trend 单调增- #!/usr/bin/perl
- #@ARGV = 'TEST.txt'; # txt not xlsl
- my $title = <DATA>;
- my @title = split /\t/, $title;
- my $lkey = @title - 4; # 忽略 vt 和 corner 列
- $title[0] = '';
- my %h;
- while (<DATA>) {
- my @a = split;
- my ( $first, $value, @last ) = @a[ 0, -1, -3, -2 ];
- for my $i ( 1 .. $lkey ) {
- my $key = $a[$i];
- # 忽略 key 的值是字符的单调性检查(vt 和 corner列)
- # 忽略 t_clk_r_q_r
-
- my @other = @a[ 1 .. $i - 1, ( $i + 1 ) .. $lkey ];
- my $other = join '|', @other;
- push @{ $h{$i}{$other}{X} }, $key;
- push @{ $h{$i}{$other}{Y} }, $value;
- $h{$i}{$other}{Z} ||= [ $first, @other, @last ];
- }
- }
- for my $i ( 1 .. $lkey ) {
- my $kv = $title[$i];
- my $keys = join "\t", @title[ 0, 1 .. $i - 1, ( $i + 1 ) .. $#title - 1 ];
- while ( my ( undef, $v ) = each %{ $h{$i} } ) {
- my @X = @{ $v->{X} };
- my @Y = @{ $v->{Y} };
- my @Z = @{ $v->{Z} };
- # 如果 key 都一样,value 是不会有两个值的。then
- # my @index = sort { $X[$a] <=> $X[$b] } 0 .. $#X;
- # else use this line
- my @index = sort { $X[$a] <=> $X[$b] || $Y[$a] <=> $Y[$b] } 0 .. $#X;
- @X = @X[@index];
- @Y = @Y[@index];
- my $Y0 = join '|', @Y;
- my $Y = join '|', sort { $a <=> $b } @Y;
- print
- $keys, "\n",
- join( "\t", @Z ), "\n",
- $kv, "\t", join( "\t", @X ), "\n",
- 'value', "\t", join( "\t", @Y ), "\n",
- 'trend', "\t", (
- # if data 有 @X only 1 element: then add this line
- @X == 1 ? '只有这一个' : # 可以注解此行 if all @X >= 2
-
- $Y0 eq $Y
- ? '单调增'
- : do {
- $Y = join '|', sort { $b <=> $a } @Y;
- $Y0 eq $Y ? '单调减' : '没有单调性';
- }
- ),
- "\n", "\n";
- }
- }
- __DATA__
- alpha beta gamma vt corner value
- matter 3 2 1 x y 0.3
- matter 5 2 2 x z 0.4
- matter 3 2 1 x b 0.2
- matter 2 2 2 b a 0.2
- matter 6 2 1 x c 0.1
- matter 7 2 2 b n 0.5
- matter 8 2 1 k m 0.2
- matter 9 2 1 u o 0.1
- matter 9 2 3 x y 0.7
- matter 10 2 3 x y 0.5
- matter 11 2 3 x y 0.3
复制代码 回复 15# cecial
|
|