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:
and it says: 3494 but##!/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";
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, addedwc -l ofphl
and went on with coding...map ( {s/\"(.*)\"/$1/;$_}) split(/,/)
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 ).
|
---|