Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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 ( 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

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2022-06-26 17:41 GMT
Find Nodes?
    Voting Booth?
    My most frequent journeys are powered by:

    Results (86 votes). Check out past polls.