X
Xaver Biton
Hi,
I'm running activestate 5.8 on winmaschine and I'm not very familiar
with perl but I like it very much.
Please be patient.
I've to split a csv file and insert it in a mysql db. I've done some
tests with other file and it worked wonderfull now in the real work
doesn't work, I' ve many errors.
The first question ist: why does perl complain when it find a "@" a "."
or a number in csv file. Perl says that it find an a number or a dot
.... where opeator is espected. how can I get rid of this?
The second question which I can't anderstand it at all is, when I
execute the script and give the csv file as parameter I recieve this
error message:
Can't locate object method "Ilzasname" via package "Asan" (perhaps you
forgot to load "Asan"?) at customers.csv line 1.
*** Process "C:\Perl\bin\perl.exe" terminated. Return code=255
the csv file is like this:
100742;ASAN;Herr;Ilzasname Asan;Steingoetter-Greiff-StrDOT
;69168;Wiesloch;;;20020425;
10074;ASAN;Herr;Ilzasname Asan;Steingoetter-Greiff-StrDOT
;69168;Wiesloch;;;20020425;hansgkoenigetaolDOTcom;
100744;ASAN;Herr;Ilzasname Asan;Steingoetter-Greiff-StrDOT
;69168;Wiesloch;;;20020425;
hier is the perl script:
use DBI;
#use strict;
# Declare and initialize variables
my $host = 'localhost';
my $db = 'dbname';
my $db_user = 'username';
my $db_password = 'password';
$dbh = DBI->connect("dbi:mysql:$db:$host", "$db_user", "$db_password",
{RaiseError => 0, PrintError => 0} );
$sth = $dbh->prepare("INSERT INTO test(vo_nr, interne_customer_id,
nikname, salutation, name, forename, address, zip, city, tel, telefax,
customer_since, mail) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)");
while(<>){
chomp;
my ($interne_customer_id, $nikname, $salutation, $name, $address,
$zip, $city, $tel, $telefax, $customer_since, $mail) = split /;/;
($name,$forename) = split(/\s+/,$name);
my $vo_nr = '012345';
$sth->execute($vo_nr, $interne_customer_id, $nikname, $salutation,
$name, $forename, $address, $zip, $city, $tel, $telefax,
$customer_since, $mail);
}
Thks. for help.
Xaver
I'm running activestate 5.8 on winmaschine and I'm not very familiar
with perl but I like it very much.
Please be patient.
I've to split a csv file and insert it in a mysql db. I've done some
tests with other file and it worked wonderfull now in the real work
doesn't work, I' ve many errors.
The first question ist: why does perl complain when it find a "@" a "."
or a number in csv file. Perl says that it find an a number or a dot
.... where opeator is espected. how can I get rid of this?
The second question which I can't anderstand it at all is, when I
execute the script and give the csv file as parameter I recieve this
error message:
Can't locate object method "Ilzasname" via package "Asan" (perhaps you
forgot to load "Asan"?) at customers.csv line 1.
*** Process "C:\Perl\bin\perl.exe" terminated. Return code=255
the csv file is like this:
100742;ASAN;Herr;Ilzasname Asan;Steingoetter-Greiff-StrDOT
;69168;Wiesloch;;;20020425;
10074;ASAN;Herr;Ilzasname Asan;Steingoetter-Greiff-StrDOT
;69168;Wiesloch;;;20020425;hansgkoenigetaolDOTcom;
100744;ASAN;Herr;Ilzasname Asan;Steingoetter-Greiff-StrDOT
;69168;Wiesloch;;;20020425;
hier is the perl script:
use DBI;
#use strict;
# Declare and initialize variables
my $host = 'localhost';
my $db = 'dbname';
my $db_user = 'username';
my $db_password = 'password';
$dbh = DBI->connect("dbi:mysql:$db:$host", "$db_user", "$db_password",
{RaiseError => 0, PrintError => 0} );
$sth = $dbh->prepare("INSERT INTO test(vo_nr, interne_customer_id,
nikname, salutation, name, forename, address, zip, city, tel, telefax,
customer_since, mail) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)");
while(<>){
chomp;
my ($interne_customer_id, $nikname, $salutation, $name, $address,
$zip, $city, $tel, $telefax, $customer_since, $mail) = split /;/;
($name,$forename) = split(/\s+/,$name);
my $vo_nr = '012345';
$sth->execute($vo_nr, $interne_customer_id, $nikname, $salutation,
$name, $forename, $address, $zip, $city, $tel, $telefax,
$customer_since, $mail);
}
Thks. for help.
Xaver