in reply to High Density Data Aid - swapping specific combination of lines/columns repeatedly

If you have enough memory, just put all your data in a hash of arrays.
my %hash; while (<$fh>) { chomp; my @data = split /\s+/; push @{$hash{$data[0]}}, @data[3,4]; } for my $key (sort keys %hash) { print join(' ', $key, @{$hash{$key}}), "\n"; }
  • Comment on Re: High Density Data Aid - swapping specific combination of lines/columns repeatedly
  • Download Code

Replies are listed 'Best First'.
Re^2: High Density Data Aid - swapping specific combination of lines/columns repeatedly
by Renyulb28 (Novice) on Apr 13, 2011 at 18:48 UTC
    with that method, how can I specific my parameters of lines that I wish to move to the right of the previous set of 142 samples from columns 4 and 5?

      By move to the right, I take it you mean append each new measurement to the appropriate sample's list.

      Given that each row contains the sample's name, we don't need to keep track of the fact that there are exactly 142 samples. Instead, this just adds each subsequent measurement to that sample's array of values. And at the end we write out all the results associated with each sample.

        so should the
        @data[3,4]
        be
        @data[4,5]
        instead since the observations are columns 4 and 5?
        when we run that in terminal with our text file nothing happens; as in no error messages show up and the text file does not change at all. Can you provide an example of how the script you imagine should look when using it with the text file?