Thanks Doug for your two-step solution.

Asish, I'm not sure why your database missing values are coming back as "". Are 
they actually NULLs in the db or something else? What is the code fragment 
that's causing the error?
$PDL::undefval would need to be set to something numeric I assume as would 
badvalue().

Regards,
Trevor.

----- Original Message -----
From: Ashish Mahabal <[EMAIL PROTECTED]>
Date: Wednesday, May 23, 2007 6:23 pm
Subject: Re: [Perldl] Re: PDL and databases
To: Trevor Carey-Smith <[EMAIL PROTECTED]>

> 
> Hello Trevor,
> 
> My problem seems to be similar to yours. I have a DB table with 
> many 
> misisng values. I get messages from ODl saying:
> 
> Argument "" isn't numeric in subroutine entry at 
> /usr/lib/perl5/vendor_perl/5.8.7/i386-linux/PDL/Core.pm line 
> 652, <DATA> 
> line 386.
> 
> Do you think badvalue (or undefvalue) can be set to ""? I tried
> $PDL::undefval = "";
> but that didn't work.
> 
> My question then is "how to make pdl accept undef values?" 
> (rather than 
> get rid of bad values). Any ideas? Else I will ask the list.
> 
> Cheers,
> ashish
> 
> 
> On Wed, 23 May 2007, Trevor Carey-Smith wrote:
> 
> > Apologies for the mailbox clutter, but I've answered my own 
> question...>
> > $PDL::undefval = -999;
> >
> > is the easy solution!!!
> >
> > Can $PDL::undefval be set to BAD somehow??
> >
> > Trevor.
> >
> > ----- Original Message -----
> > From: Trevor Carey-Smith <[EMAIL PROTECTED]>
> > Date: Wednesday, May 23, 2007 4:15 pm
> > Subject: PDL and databases
> > To: perldl list <[email protected]>
> >
> >> Hi,
> >>
> >> I'm trying to extract data from an oracle database directly into
> >> piddles. The method below suggested by Doug works, except when
> >> there are NULL values in the database. These all end up as
> >> zeroes in the piddle. Does anyone know of a workaround to
> >> this... perhaps setting the value to bad?
> >>
> >> Regards,
> >>
> >> Trevor.
> >>
> >>
> >> ----- Original Message -----
> >>
> >>
> >> From: Doug Hunt <[EMAIL PROTECTED]>
> >>
> >>
> >> Date: Tuesday, July 4, 2006 10:17 am
> >>
> >>
> >> Subject: Re: Fw: PDL Getting Started book Re: [Perldl] IDL thing
> >>
> >>
> >> To: [EMAIL PROTECTED]
> >>
> >>
> >> Cc: perldl list <[email protected]>
> >>
> >>
> >>
> >>
> >>
> >>> Hi Celia:
> >>
> >>
> >>>
> >>
> >>
> >>> In many cases its easy to get SQL database info into a 2D PDL.
> >>
> >>
> >>>
> >>
> >>
> >>> We use postgres, so I often say something like:
> >>
> >>
> >>>
> >>
> >>
> >>> my $db     = 
> "dbi:Pg:dbname=$dbname;host=$dbhost";>>
> >>
> >>> my $dbh    = DBI->connect($db);
> >>
> >>
> >>> die "Cannot connect to database = $dbname, dbhost = $dbhost"
> >>
> >>
> >>> unless (defined($dbh));
> >>
> >>
> >>>
> >>
> >>
> >>> my $sql = "select id, value1, value2 from table1 where ...";
> >>
> >>
> >>>
> >>
> >>
> >>> my $p = pdl ( $dbh->selectall_arrayref($sql) );
> >>
> >>
> >>>
> >>
> >>
> >>> This works provided all the selected values are numeric.
> >>
> >>
> >>>
> >>
> >>
> >>> Regards,
> >>
> >>
> >>>
> >>
> >>
> >>>    Doug
> >>
> >>
> >>>
> >>
> >>
> >>> [EMAIL PROTECTED]
> >>
> >>
> >>> Software Engineer III
> >>
> >>
> >>> UCAR - COSMIC, Tel. (303) 497-2611
> >>
> >>
> >>>
> >>
> >>
> >>> On Wed, 28 Jun 2006, [EMAIL PROTECTED] wrote:
> >>
> >>
> >>>
> >>
> >>
> >>>>
> >>
> >>
> >>>> I sort of got into PDL because it sounded a very interesting
> >>
> >>
> >>> way to do data
> >>
> >>
> >>>> manipulation.  But I found it very hard to get going. I
> >>
> >>
> >>> also found it was
> >>
> >>
> >>>> hard to find stuff unless you exactly knew what you where
> >>
> >>
> >>> doing and what it
> >>
> >>
> >>>> was named.  It was also very hard to find example
> >>
> >>
> >>> scripts.   I love example
> >>
> >>
> >>>> scripts it is how I learn stuff.
> >>
> >>
> >>>>
> >>
> >>
> >>>> My problem was that most of my files where in comma
> >> delimited
> >>
> >>
> >>> format or
> >>
> >>
> >>>> from relational databases ( which I used a dbi modules to
> >>
> >>
> >>> get).  I really
> >>
> >>
> >>>> wanted example of how to get data from the following sources
> >>
> >>
> >>> into PDL.  But
> >>
> >>
> >>>> I found it hard to find resources and also ran out of
> >>
> >>
> >>> time.  So I didn't
> >>
> >>
> >>>> end up doing it.
> >>
> >>
> >>>>
> >>
> >>
> >>>> Celia
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>             Donald Jackson
> >>
> >>
> >>>>             <[EMAIL PROTECTED]
> >>
> >>
> >>>>
> >> 
> ms.com>                                                    To
> >>
> >>
> >>>>
> >>
> >>
> >>>>             28/06/2006
> >> 
> 12:43                                           cc
> >>
> >>
> >>>>             AM
> >>
> >>
> >>>
> >>>                                                                   Subject
> >>
> >>
> >>>>                                       Re: PDL Getting
> >> Started book Re:
> >>
> >>
> >>>>                                       [Perldl] IDL thing
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>> As a newbie user, I can attest to the need- the POD is
> >> pretty
> >>
> >>
> >>> good, but
> >>
> >>
> >>>> it's like a dictionary: you need to know what to look for in
> >>
> >>
> >>> order to
> >>
> >>
> >>>> find it!
> >>
> >>
> >>>>
> >>
> >>
> >>>> I'd happily volunteer as a guinea pig for testing drafts on.
> >>
> >>
> >>>>
> >>
> >>
> >>>> Don Jackson
> >>
> >>
> >>>>
> >>
> >>
> >>>> Xavier Calbet wrote:
> >>
> >>
> >>>>
> >>
> >>
> >>>>>  If you all agree, we could start writing
> >>
> >>
> >>>>> a simple introductory PDL book...
> >>
> >>
> >>>>>
> >>
> >>
> >>>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>> _______________________________________________
> >>
> >>
> >>>> Perldl mailing list
> >>
> >>
> >>>> [email protected]
> >>
> >>
> >>>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>>
> >>
> >>
> >>>> _______________________________________________
> >>
> >>
> >>>> Perldl mailing list
> >>
> >>
> >>>> [email protected]
> >>
> >>
> >>>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
> >>
> >>
> >>>>
> >>
> >>
> >>>
> >>
> >>
> >>> _______________________________________________
> >>
> >>
> >>> Perldl mailing list
> >>
> >>
> >>> [email protected]
> >>
> >>
> >>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
> >>
> >>
> >>>
> >>
> >
> > _______________________________________________
> > Perldl mailing list
> > [email protected]
> > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
> >
> 
> Ashish Mahabal, Caltech Astronomy, Pasadena, CA 91125
> http://www.astro.caltech.edu/~aam aam at astro.caltech.edu
> 
> We are the people our parents warned us about.
>
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to