Hi all, i recently found out that i can use DBI's DBD::CSV component to access a text file much like a tabl in a database (with some notable differences). Now i am useg this code below to read a file BUT everytime i run the script it just returns the first line and ignores the remaining.

The file format of the data file is (delimited with "!"s):

1018884184639!1!2!3!4!5!6!7!8!9!10!11!12!http://www.perlmonks.com!Fri +Mar 29 10:32:44 2002! 1017939028902!1!2!3!4!5!6!7!8!9!10!11!12!http://perlmonks.com!Fri Mar +29 10:32:44 2002! 1017939144004!1!2!3!4!5!6!7!8!9!10!11!12!http://perlmonks.com!Fri Mar +29 10:32:44 2002!

And here is what my code looks like so far:

use DBI; $dbh = DBI->connect("DBI:CSV:f_dir=/export/home/devtools") or die "Cannot connect: " . $DBI::errstr; # reading "devtools.data" as a table: $dbh = DBI->connect(qq{DBI:CSV:csv_sep_char=\\!}); $dbh->{'csv_tables'}->{'devtools'} = { 'file' => 'devtools.data'}; $dbh->{csv_tables}->{'devtools'}->{skip_rows} = 0; $dbh->{csv_tables}->{'devtools'}->{col_names} = [qw(id pp midd fos db dbt dlang fil dtools stools scm tt dest +url lastupdate )]; $sth = $dbh->prepare("SELECT id, url FROM devtools"); $sth->execute() or die "Cannot execute: " . $sth->errstr(); #DBI->trace(1); while ( ( $id, $url) = $sth->fetchrow_array) { print "ID is - $id , and url is - $url\n"; } $sth->finish();

And this returns (just one record???):
ID is - 1018884184639 , and url is - http://www.perlmonks.com

Why is it not going through the whole file? WHat am i not doing right.
Thanks


In reply to reading files with DBD::CSV by data67

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.