]> git.nbdom.net Git - nb.git/commitdiff
Fix bug adding missing columns
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 16 Apr 2023 21:54:10 +0000 (23:54 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 16 Apr 2023 21:54:10 +0000 (23:54 +0200)
bin/csv2human

index b708251ea7263e26bc0b3791c9270ad38c5293f3..eda3028cf064bcc95c1c8a92683e6426c520e079 100755 (executable)
@@ -73,16 +73,27 @@ print $sep_line;
 
 my $i = 0;
 my $count;
-while ($_ = shift @lines) {
-       if ($i == 0) {
-               $count = @$_;
-       } else {
-               for (my $j=@$_; $j<$count; $j++ ) {
-                       $_->[$j] = '';
-               }
+while (my $line = shift @lines)
+{
+       # NB 16.04.23: I guess it was supposed ad missing columns   
+       # NB 16.04.23 if ($i == 0)
+       # NB 16.04.23 {
+               # NB 16.04.23 $count = @$line;
+       # NB 16.04.23 }
+       # NB 16.04.23 else
+       # NB 16.04.23 {
+               # NB 16.04.23 for (my $j=@$line; $j<$count; $j++ )
+               # NB 16.04.23 {
+                       # NB 16.04.23 $line->[$j] = '';
+               # NB 16.04.23 }
+       # NB 16.04.23 }
+       # Add missing empty columns
+       for (my $j=@$line; $j<@len; $j++ )
+       {
+               $line->[$j] = '';
        }
 
-       printf $format,@$_;
+       printf $format,@$line;
        print $sep_line if $Opt{header} and !$i++;
 }