perl DBD::CSV; col0, col1, ... automatisch

Post Reply
Message
Author
Perl Gast

perl DBD::CSV; col0, col1, ... automatisch

#1 Post by Perl Gast »

Hallo!
Hat jemand Erfahrung mit der "automatischen Spalten-Namen-Generierung" im DBD::CSV-Modul? Funktioniert bei mir nicht, bin zu blöd für Perl (für VB reicht es auch nicht.)

perldoc DBD::CSV sagt:

Code: Select all

col_names
skip_first_row
  By default DBD::CSV assumes that column names are stored 
  in the first row of the CSV file. If this is not the case, you can 
  supply an array ref of table names with the col_names
  attribute. In that case the attribute skip_first_row will be set 
  to FALSE.
  If you supply an empty array ref, the driver will read the first
  row for you, count the number of columns and create column
  names like "col0", "col1", ...
Verstehe ich "If you supply an empty array ref ..." falsch?

Code: Select all

  $dbh->{ 'csv_tables' }->{ 'kfzst' } =
  {
	'file'		=> $table,
	'col_names'	=> []
  };
  # Fehlermeldung:
  # Connected to:
  # DBI:CSV:f_dir=/tmp/DOS-PC/p/kfz/export/;csv_sep_char=\;
  # Execution ERROR: Couldn't find column names!.
  # DBD::CSV::st execute failed: 
  # Execution ERROR: Couldn't find column names!.
So funktioniert es, ist aber nicht das Ziel und bei unbekannter Spaltenzahl nicht anwendbar:

Code: Select all

...
	'col_names'	=> [ "COL0", "COL1", "COL2", ...
...
Vielen Dank

Post Reply