[9fab9f]: / modules / RawDB / scripts / transposeCSV.pl

Download this file

25 lines (20 with data), 418 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl
my @rows = ();
my @transposed = ();
open F1,"data.csv";
while(<F1>) {
chomp;
push @rows, [split /,/ ];
}
#print @rows;
for my $row (@rows) {
for my $column (0 .. $#{$row}) {
push(@{$transposed[$column]}, $row->[$column]);
}
}
for my $new_row (@transposed) {
for my $new_col (@{$new_row}) {
print $new_col, ",";
}
print "\n";
}