Hi Monks,
I have a question about re-organising entries. Currently ,I have files with entries that look like this:
1 SP_85(IS33, qqq), SP_155(IS33eee) spr_111(ISyyy33, qqq), spr_1 +71(IS33eee) 2 SP_83(S3 , jgjg), SP_32(IS33, jhdjdjd) spr_113(Stty3 , jgjg), +spr_1881(IS33, jhdjdjd) 3 SP_78(3jmdsjkdej), SP_66(IShbdhdhd33) spr_115(3jmhhggggdsjkdej +), spr_1551(IShbdhdjjjhd33), spr_88881(Iyt33ff), spr_145411(Iddd3ff) 4 SP_77(3jmdsjkdej), SP_1485(Idhd33ff) spr_116(3jmdhhhhhsjkdej), + spr_17781(Idhdhhtytyt33ff)
How do I re-organise them so that all entries with a similar name will be in the same column
Here is my desired output:
1 SP_85(IS33, qqq) spr_111(ISyyy33, qqq) 1 SP_155(IS33eee) spr_171(IS33eee) 2 SP_83(S3 , jgjg) spr_113(Stty3 , jgjg) 2 SP_32(IS33, jhdjdjd) spr_1881(IS33, jhdjdjd) 3 SP_66(IShbdhdhd33) spr_115(3jmhhggggdsjkdej) 3 SP_66(IShbdhdhd33) spr_1551(IShbdhdjjjhd33) 3 - spr_88881(Iyt33ff) 3 - spr_145411(Iddd3ff) 4 SP_77(3jmdsjkdej) spr_116(3jmdhhhhhsjkdej) 4 SP_1485(Idhd33ff) spr_17781(Idhdhhtytyt33ff)
Please bear in mind that I have hundreds of columns and thousands of rows
The code i have tried implementing so far:
my $columnFile = q{re-organized.txt}; open my $columnFH, q{<}, $columnFile or die qq{open: < $columnFile: $!\n}; my @results; while ( <$columnFH> ) { my @cols = split; foreach my $idx ( 0 .. $#tests ) { foreach my $subidx ( 0 .. $#{ $tests[ $idx ] } ) { my @posns = split m{,}, $tests[ $idx ]->[ $subidx ]; $results[ $idx ]->[ $subidx ] ++ if scalar @posns == grep { q{z} eq $cols[ $_ ] } @posns; } } } close $columnFH or die qq{close: < $columnFile: $!\n};
Thanks,
$new_guy
In reply to Re-organising entries by $new_guy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |