Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: CSV column names

by erix (Prior)
on Aug 27, 2016 at 11:04 UTC ( [id://1170577]=note: print w/replies, xml ) Need Help??


in reply to Re^2: CSV column names
in thread CSV column names

"working", "not working" ? -- please be more explicit: what happens when you do what, exactly? What and why is unexpected?

Post the code and the first few lines of the files (10 lines or so will do).

Replies are listed 'Best First'.
Re^4: CSV column names
by Anonymous Monk on Aug 27, 2016 at 11:27 UTC

    When i run the following script

    #!/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"; }
    It won't work if the table(info) was made using sql students

      Take a look at the first line of the CSV file. It should contain your column names but it sounds like the file only contains the data.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1170577]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-25 12:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found