Question : LOAD DATA INFILE

How to have log messages (Status), if we want to load data (LOAD DATA INFILE) from csv file to mysql database through a perl program

Answer : LOAD DATA INFILE

Try this;

Once you have the data read in from the csv, it's then just a matter of creating a dynamic $sql query for your inserts.

Hope this helped.

~A~
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
# General csv parser
my $parser = Text::CSV::Simple->new;
my @data = $parser->read_file($datafile);
print @$_ foreach @data;

# Only want certain fields?
my $parser = Text::CSV::Simple->new;
# specify the columns that you want pulled from the csv
$parser->want_fields(1, 2, 4, 8);
my @data = $parser->read_file($datafile);

# Map the fields to a hash?
my $parser = Text::CSV::Simple->new;
$parser->field_map(qw/id name null town/);
my @data = $parser->read_file($datafile);
Random Solutions  
 
programming4us programming4us