Hello Monks

I think I hit the wall with DBD::CSV module, it seems like it ignores most of rows in my file.

It all started as a success-story with DBD::CSV - I had some data in CSV format, and to access it I used loop and split

while (<FILE>) { my ($one,$two,$three..etc)=split(/,/); }

This works... but some/most of the entries are now enclosed in "", so instead of 1 I've got "1". So I go and check if someone solved the problem... and I recall using DBD::CSV long time ago..

And it's magical, it works, the code is shorter, and works correctly... all rejoice and I go on writing app built on top of DBD::CSV..until I hit some strange problems.. It looks like some selects return empty resultset when they shouldn't... So i:

##!/usr/bin/perl use DBI; tdbh = DBI->connect("DBI:CSV:") or die "Cannot connect: " . $DBI::errstr; my $sth = $tdbh->prepare("select * from ofphl"); $sth->execute(); while ($sth->fetch()) {$i++;}; print ": $i \n";
and it says: 3494 but
wc -l ofphl
says 164375. Something is obviously wrong here... I looked at 3494 row and few around it, and they look fine.. So after a while I returned to my old code, added
map ( {s/\"(.*)\"/$1/;$_}) split(/,/)
and went on with coding...

I'm not sure that's how one's supposed to use map though...

Anyhoo... DBD::CSV looks like it's been dead for quite some time now.. mailing lists mentioned in documentation moved etc...

Update I received reply from the author, mailinglist users now sit at dbi-users@perl.org ( could've found it myself with google help, but still it's nice if documentation points to existing datasources ).

Text::CSV_XS seems like it solves my problem ( I just needed a convienient way of reading CSV file, not a way to work on it ).


In reply to DBD::CSV limitation versus aging/unmaintained modules by Eyck

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.