DBD::CSV::st execute failed:
Execution ERROR: Cannot open afs: No such file or directory at C:/Perl64/lib/DBD/File.pm line 565
####
# Create connection string to database point.csv (output file from scadaexport.pl)
my $dbh = DBI->connect ("dbi:CSV:csv_auto_diag=1", {
f_dir => ".",
f_ext => ".csv/r",
f_enc => "utf-8",
file => "point.csv",
});
# Associate our csv file with the table name "AFS" and include custom column names
$dbh->{csv_tables}->{AFS} =
{
file => "point.csv",
col_names => [qw( RECORD SUBSCRIPT ID_SUBSTN CO_SUBSTN AREA_SUBSTN ID_DEVTYP ID_DEVICE NAME_DEVICE AREA_DEVICE ID_MEAS ID_POINT SITE_POINT AREA_POINT )],
};
# Define and Execute SQL to select INTELI and AUTO points
my $sth = $dbh->prepare ("select * from AFS where ID_DEVTYP like 'INTELI%' AND ID_POINT like 'AUTO%'");
$sth->execute;
####
my @col = qw(RECORD SUBSCRIPT ID_SUBSTN CO_SUBSTN AREA_SUBSTN ID_DEVTYP ID_DEVICE NAME_DEVICE AREA_DEVICE ID_MEAS ID_POINT SITE_POINT AREA_POINT);
my $cols = join ",",@col;
# Create connection string to database point.csv
my $dbh = DBI->connect ("dbi:CSV:", undef, undef, {
f_ext => ".csv/r",
f_encoding => "utf-8",
});
my $sth = $dbh->prepare ("SELECT $cols FROM point WHERE ID_DEVTYP LIKE 'INTELI%' AND ID_POINT LIKE 'AUTO%'");
$sth->execute;
####
my @col = qw(RECORD SUBSCRIPT ID_SUBSTN CO_SUBSTN AREA_SUBSTN ID_DEVTYP ID_DEVICE NAME_DEVICE AREA_DEVICE ID_MEAS ID_POINT SITE_POINT AREA_POINT);
my $cols = join ",",@col;
# Create connection string to database point.csv (output file from scadaexport.pl)
my $dbh = DBI->connect ("dbi:CSV:", undef, undef,
{
f_encoding => "utf-8",
});
# Define and Execute SQL to select INTELI and AUTO points
my $sth = $dbh->prepare ("select $cols from point.csv where ID_DEVTYP like 'INTELI%' AND ID_POINT like 'AUTO%'");
$sth->execute;
####
use warnings;
use strict;
use DBI;
my @col = qw(RECORD SUBSCRIPT ID_SUBSTN CO_SUBSTN AREA_SUBSTN ID_DEVTYP ID_DEVICE NAME_DEVICE AREA_DEVICE ID_MEAS ID_POINT SITE_POINT AREA_POINT);
my $cols = join ",",@col;
# Create connection string to database point.csv (output file from scadaexport.pl)
my $dbh = DBI->connect ("dbi:CSV:", undef, undef,
{
f_encoding => "utf-8",
});
# Define and Execute SQL to select INTELI and AUTO points
my $sth = $dbh->prepare ("select $cols from point.csv where ID_DEVTYP like 'INTELI%' AND ID_POINT like 'AUTO%'");
$sth->execute;
# Create AFS CSV with Columns
open (DAT_OUTPUT,">AFS.csv");
print DAT_OUTPUT "RECORD,SUBSCRIPT,ID_SUBSTN,CO_SUBSTN,AREA_SUBSTN,ID_DEVTYP,ID_DEVICE,NAME_DEVICE,AREA_DEVICE,ID_MEAS,ID_POINT,SITE_POINT,AREA_POINT\n";
# Cycle through SQL results on ROW basis and print to AFS CSV file
while (my $row = $sth->fetchrow_hashref)
{
print DAT_OUTPUT "$row->{RECORD},$row->{SUBSCRIPT},$row->{ID_SUBSTN},$row->{CO_SUBSTN},$row->{AREA_SUBSTN},$row->{ID_DEVTYP},$row->{ID_DEVICE},$row->{NAME_DEVICE},$row->{AREA_DEVICE},$row->{ID_MEAS},$row->{ID_POINT},$row->{SITE_POINT},$row->{AREA_POINT}\n";
}
# Close file
close DAT_OUTPUT;