in reply to Consolidating nstore arrays
This is not turn key code, but hopefully it will provide some guidance.
Some problems:
I don't understand your pattern, it doesn't look perlish.
Certainly comment out test data generation.
There will be problems if input files have different sizes.
This uses my current favorite Path::Tiny but could be adopted to others.
#!/usr/bin/perl # http://perlmonks.org/?node_id=1198355 use strict; use warnings; use Path::Tiny; use Storable qw(nstore retrieve); my $column = 1; # these could be passed i +n... my $filepattern = qr/(thing.*).foo__bar_ar/; my $projectdirectory = './some'; # make test data path("$projectdirectory/$_")->mkpath for qw( one two/three ); nstore [[1.34, 2.53], [3.26, 4.001]], "$projectdirectory/one/thing1.fo +o__bar_ar"; nstore [[5.55, 6.911], [7.373, 8.808]], "$projectdirectory/two/three/thing3.foo__bar_ar"; # end make test data my @answer; my $header = 'Number'; path($projectdirectory)->visit( sub { my ($path) = @_; /$filepattern/ or return; $header .= ", $1"; my $arrayref = retrieve($path); my $number = 0; $answer[$number++] .= ", " . $_->[$column] for @$arrayref; }, { recurse => 1 } ); my $number = 1; $_ = $number++ . "$_\n" for @answer; print "$header\n", @answer;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Consolidating nstore arrays
by Speed_Freak (Sexton) on Aug 31, 2017 at 19:50 UTC | |
by tybalt89 (Monsignor) on Aug 31, 2017 at 20:01 UTC | |
by Speed_Freak (Sexton) on Aug 31, 2017 at 20:29 UTC | |
by tybalt89 (Monsignor) on Aug 31, 2017 at 20:45 UTC | |
by afoken (Chancellor) on Sep 01, 2017 at 06:51 UTC | |
| |
by Anonymous Monk on Aug 31, 2017 at 23:31 UTC |