Drkcore

28 08 2007 perl Tweet

Text::CSV::Simpleでピボット

単純なピボットがしたかった。

use Text::CSV::Simple;
my $file = shift;

my $parser = Text::CSV::Simple->new;
my @list = qw/cl1 cl2 cl3 cl4 cl5/;
$parser->field_map(@list);
my @data = $parser->read_file($file);

my $pivdata = {};

for my $d (@data){
 for my $label (@list){
   push @{$pivdata->{$label}},$d->{$label};
 }
}

for my $label (@list){
 print join ",", @{$pivdata->{$label}};
 print "\n";
}

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021