in reply to Re^3: CSV column names
in thread CSV column names
When i run the following script
It won't work if the table(info) was made using sql students#!/bin/env perl use strict; use warnings; use DBI; my $dbh = DBI->connect('DBI:CSV:'); $dbh->{csv_tables}{info} = { file => 'info.csv' }; my $qu = $dbh->prepare('select * from info'); $qu->execute(); my @cols = @{$dbh->{csv_tables}{info}{col_names}}; # col_names won't b +e defined until you've queried the file. print "column names: @cols\n"; while( my @row = $qu->fetchrow_array) { print "row: @row\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: CSV column names
by Mr. Muskrat (Canon) on Aug 29, 2016 at 13:51 UTC |