On Tue, Mar 25, 2008 at 9:22 PM, Dennis G. Wicks <[EMAIL PROTECTED]> wrote:
> Greetings,
>
>  I get data in CSV files from several different sites
>  and I can't get the date/time formats to be consistent,
>  let alone have the fields arranged in the same order.
>

Dennis,

First of all, I wouldn't suggest trying to parse csv yourself, unless
you are absolutely sure the data will be well-behaved. If a name like
John Doe, Jr. shows up your data or someone hits "," instead of "m",
things can go south in a hurry if you're using a simple split to parse
your records. That assumes, of course, that you csv,really is csv. If
your files are tab or pipe-delimited, life is a little simpler.

There are a number of modules on CPAN designed to make dealing with
CSV more pleasant.; look around and see what suits your needs. for
this particular case, DBD::CSV might be a god place to start. It
basically lets you treat a csv file as a database, so you can do
things like:

while (my $row = $csv->fetchrow_hashref) {
    print $row->{'name'}, "\t", $row->{'email'}, "\n";
}

HTH,

-- j
--------------------------------------------------
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org

values of β will give rise to dom!

Reply via email to