help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getting numerical datas from postgres


From: Alain
Subject: getting numerical datas from postgres
Date: Wed, 25 Feb 2009 02:44:35 +0100
User-agent: KMail/1.9.9

Hello 

I would like to retrieve numerical data from postgresql database.

i installed the database-1.0.tgz pkg, which import data in "cell" then i 
convert to string then to num (for decimal numbers). But the "for" loop is  
very slow (near 1 second for 10000 fields).

stuff=sql("select stuff.* from stuff,lieu where stuff.id_lieu=lieu.id and 
lieu.ville='Paris';");

# convert cell to numbers
s=size(stuff)(1);
t=zeros(s,1);
h=zeros(s,1);

# t is signed decimal (eg -12.3)
for i=1:s
        t(i) = str2num( cell2mat( stuff(i,2) ) );
endfor

# h is unsigned int (eg 87)
h = cell2mat( stuff(:,4) );


1/ it would be ok without the "for" loop, but i failed to avoid it (like for 
the h vector). What is wrong in my import/conversion ?

2/ i found the (old) pgnumdata  
(http://dirk.eddelbuettel.com/code/octave-pg/pgnumdata.cc.txt)
but i cannot build it (instruction given in the end of the file)
- i don't find headers  libq++.h
- PgDatabase seems to have disapeared from pg (i guess pgnumdata is rather old 
and used to work with older version of octave and postgres).
 Is there a new version or something equivalent ?

Thanks in advance for any help/url/hint ....
Best regards.
Alain.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]