hi everyone

Here's an update on my problem -

When I remove the linefeeds from between the lines in the csv file, it works.

Here's the strange thing - those linefeeds were put in there by my insert
statements from inside perl DBI::CSV under mac.

so it's emiting one eol character (cr and lf) and expecting another (just cr)

I'm trying to see if I can fix the eol problem in the $dbh hash, but I'm
beginning to get confused now.

Yours
Jin

> Hi everyone,
>
> I've got another newbie question -
>
> I'm able to grab the correct number of rows out of the csv file no
> problems now, but the actual values in the rows are blank.
>
> If I have the following file
> # this comment not part of the csv file
> custID,family,given^M
>
> 1,adams,mortica^M
>
> 1,adams,gomez^M
>
> 1,golden,gollum^M
>
> 1,greedy,grover^M
>
> #this comment not part of the csv file either
>
> and the following code
>
> #!/usr/bin/perl -Wall
> use strict;
> use DBI;
>
> my($dbh, $sth);
> my($key, @row);
>
> $dbh = DBI->connect("DBI:CSV:f_dir=./")
>             or die "Cannot connect: " . $DBI::errstr;
>
> $sth = $dbh->prepare("select custID,family,given from customer")
>              or die "Cannot prepare: " . $dbh->errstr();
>
> $sth->execute() or die "Cannot execute: " . $sth->errstr();
>
> print "number of rows found: ". $sth->rows;
> while(@row = $sth->fetchrow_array())
> {
>         print join("-",@row);
> }
> $sth->finish();
> $dbh->disconnect() or die "Can't disconnect ". $dbh->errstr();
> #end code that sort of works
>
> I get the following output
>
> $ ./selectcsvfile.pl
> number of rows found: 5
> Use of uninitialized value in join or string at ./selectcsvfile.pl line
> 19.
> Use of uninitialized value in join or string at ./selectcsvfile.pl line
> 19.
> --
> Use of uninitialized value in join or string at ./selectcsvfile.pl line
> 19.
> Use of uninitialized value in join or string at ./selectcsvfile.pl line
> 19.
> --
> Use of uninitialized value in join or string at ./selectcsvfile.pl line
> 19.
> Use of uninitialized value in join or string at ./selectcsvfile.pl line
> 19.
> --
> Use of uninitialized value in join or string at ./selectcsvfile.pl line
> 19.
> Use of uninitialized value in join or string at ./selectcsvfile.pl line
> 19.
> --
> Use of uninitialized value in join or string at ./selectcsvfile.pl line
> 19.
> Use of uninitialized value in join or string at ./selectcsvfile.pl line
> 19.
> --
>
> end of output
>
> which says to me that I'm retrieving all five rows, and getting the right
> number of columns in each row. but each of the values in the actual array
> are undefined.
>
> To my eye, I can't tell the difference between my code and the code up on
> here
> http://ironbark.bendigo.latrobe.edu.au/subjects/int32we/lectures/w09.d/Lect18.html
>
> on the first example of the section called SELECT subtleties.
>
> Please tell me what I'm missing?
>
> Yours
> Jin
>
>
>


Reply via email to