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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#!C:\Perl64\bin\
use strict;
use warnings;
use Text::CSV;
use Text::CSV::Encoded;
#$csv = Text::CSV::Encoded->new ({ encoding => "utf8" });
#Ouverture du fichier Client en Lecture
my $FicCli = "C:/Users/A454222/Documents/__Dev Perl/Extrait_FluxMailing_FL17_2.csv";
my $Client_Csv = Text::CSV->new ({
binary => 1, # Allow special character. Always set this
auto_diag => 1, # Report irregularities immediately
sep_char => ";"
});
open(Cli_Csv, "<", $FicCli) or die $!;
#Ouverture du fichier Agence en Lecture
my $FicAgence = "C:/Users/A454222/Documents/__Dev Perl/Extrait_FluxGuichetPriPro_FL17.csv";
my $Agence_Csv = Text::CSV->new ({
binary => 1, # Allow special character. Always set this
auto_diag => 1, # Report irregularities immediately
sep_char => ";"
});
open(Age_Csv, "<", $FicAgence) or die $!;
#Ouverture du fichier Result en Ecriture
my $FicResult = "C:/Users/A454222/Documents/__Dev Perl/Result.txt";
open(FicRes, ">", $FicResult) or die $!;
my $count = 0 ;
while (<Cli_Csv> ) {
next if ($. == 1);
if ($Client_Csv->parse($_)) {
my @columns = $Client_Csv->fields();
my $CliCodeAgence = $columns[2];
$count++;
while (<Age_Csv>) {
next if ($. == 1);
if ($Agence_Csv->parse($_)) {
my @colAgence = $Agence_Csv->fields();
my $AgeCodeAgence = $colAgence[1];
if ($AgeCodeAgence == $CliCodeAgence) {
print (FicRes "30003",";",";",$columns[19],";","FR",";",$columns[2],";",sprintf("%015u",$count),";"," ",";"," ",";"," ",";"," ",";"," ",";",$columns[14],";",$columns[15],";",$columns[16],";",$columns[17],";",$columns[18],";",$columns[19]," ",$columns[20],";",$colAgence[1],";",$colAgence[3],";",$colAgence[6],";",$colAgence[7],";",$colAgence[8]," ",$colAgence[9],";",$colAgence[10],"\n");
}
} else {
my $err2 = $Agence_Csv->error_input;
print "Failed to parse line: $err2";
}
}
} else {
my $err = $Client_Csv->error_input;
print "Failed to parse line: $err";
}
}
close FicCli ;
close FicAgence ; |
Partager