Subject: | Specifying seperation character per table does not work |
Hi there,
the following code:
--------------------------------------------------------------
my $dbh = DBI->connect("dbi:CSV:") || $mainLog->logdie("Connection
failed with error: $DBI::errstr");
$dbh->{'csv_tables'}->{'csv_data'}->{'file'} = "/tmp/test.csv";
$dbh->{'csv_tables'}->{'csv_data'}->{'eol'} = "\n";
$dbh->{'csv_tables'}->{'csv_data'}->{'sep_char'} = ";";
$dbh->{'csv_tables'}->{'csv_data'}->{'quote_char'} = undef;
$dbh->{'csv_tables'}->{'csv_data'}->{'escape_char'} = undef;
print Dumper $dbh->{'csv_tables'}->{'csv_data'};
my $stmt = qq| select * from csv_data |;
my $sth = $dbh->prepare($stmt);
$sth->execute();
--------------------------------------------------------------
produces this output:
$VAR1 = {
'f_fqbn' => '/tmp/csv_data',
'eol' => '
',
'quote_char' => undef,
'f_file' => '/tmp/volki.csv',
'csv_class' => 'Text::CSV_XS',
'f_encoding' => undef,
'initialized' => 1,
'escape_char' => undef,
'f_lockfile' => undef,
'csv_skip_first_row' => undef,
'f_fqfn' => '/tmp/volki.csv',
'f_schema' => undef,
'csv_sep_char' => ';',
'csv_in' => bless( {
'_BOUND_COLUMNS' => undef,
'verbatim' => 0,
'types' => undef,
'_AHEAD' => undef,
'_COLUMN_NAMES' => undef,
'eol' => '',
'blank_is_undef' => 0,
'_STRING' => undef,
'quote_char' => '"',
'sep_char' => ',',
'allow_whitespace' => 0,
'auto_diag' => 1,
'_ERROR_INPUT' => undef,
'escape_char' => '"',
'_FFLAGS' => undef,
'always_quote' => 0,
'allow_loose_escapes' => 0,
'_STATUS' => undef,
'allow_loose_quotes' => 0,
'keep_meta_info' => 0,
'binary' => 1,
'quote_null' => 1,
'_EOF' => 0,
'quote_space' => 1,
'_FIELDS' => undef,
'empty_is_undef' => 0
}, 'Text::CSV_XS' ),
'f_lock' => undef,
'csv_eol' => '
',
'f_dir' => '/home/vhein51/cscan',
'f_ext' => undef,
'sql_identifier_case' => 2,
'table_name' => 'csv_data',
'csv_out' => bless( {
'_BOUND_COLUMNS' => undef,
'verbatim' => 0,
'types' => undef,
'_AHEAD' => undef,
'_COLUMN_NAMES' => undef,
'eol' => '
',
'blank_is_undef' => 0,
'_STRING' => undef,
'quote_char' => '"',
'sep_char' => ',',
'allow_whitespace' => 0,
'auto_diag' => 1,
'_ERROR_INPUT' => undef,
'escape_char' => '"',
'_FFLAGS' => undef,
'always_quote' => 0,
'allow_loose_escapes' => 0,
'_STATUS' => undef,
'allow_loose_quotes' => 0,
'keep_meta_info' => 0,
'binary' => 1,
'quote_null' => 1,
'_EOF' => 0,
'quote_space' => 1,
'_FIELDS' => undef,
'empty_is_undef' => 0
}, 'Text::CSV_XS' )
};
DBD::CSV::st execute failed:
Execution ERROR: Missing first row at
/sysmgmt/opt/site_perl/x86_64-linux-thread-multi/DBD/File.pm line 684
.
----------
The csv contained the following lines:
"HEADER1";"HEADER2"
Volki;Bolki
Zolki;Solki
Seems like setting the "sep_char" or "csv_sep_char" ( I tried both )
seperately for a table does not work.
P.S.: greetings from Mr. Jens Rehsack who witnessed this phenomenon
personally ;-)