Thread Zusammenführung von .csv files klappt manchmal nicht (28 answers)
Opened by vionig at 2017-09-16 16:05

Gast Vionig
 2017-09-18 13:55
#187428 #187428
Merci.

Das mit dem $cnt scheint tatsächlich etwas zu sein, wenn ich den Codeblock unten ausführe bekomme ich (unerwartet) unterschiedliche Ausgaben... was eigentlich nicht sein sollte, da jede Datei ab diesem bestimmten Datum erst ausgelesen wird.

Ausgabe:
Quote
13536
13536
13536
13536
13536
13536
13536
13536
13536
13536
13624
13624

...


Nur wieso verstehe ich nicht.

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use strict;   
use warnings;
use lib '/var/root/perl5/lib/perl5';
use Text::CSV;

my @rows;
my $fh;
my $csv = Text::CSV->new ( { binary => 1 } ) # should set binary attribute.
or die "Cannot use CSV: ".Text::CSV->error_diag ();
my $cnt = 0;
my @Values;

my $dir = './FXE';
foreach my $fp (glob("$dir/*")) {
open my $fh, "<:encoding(utf8)", $fp or die "can't open $!";
while ( my $row = $csv->getline( $fh ) )
{
if($row->[0] >=1101227)
{
$Values[$cnt++] = $row->[0];
$Values[$cnt++] += $row->[1];
$Values[$cnt++] += $row->[2];
$Values[$cnt++] += $row->[3];
$Values[$cnt++] = $row->[4];
$Values[$cnt++] = $row->[5];
$Values[$cnt++] = $row->[6];
$Values[$cnt++] = $row->[7];

}
}
print($cnt);
print("\n");
$csv->eof or $csv->error_diag();
close $fh or die "can't close $!";
$cnt=0;
}

Last edited: 2017-09-18 14:07:11 +0200 (CEST)

View full thread Zusammenführung von .csv files klappt manchmal nicht