getting numerical datas from postgres
Alain
alain.baeckeroot at laposte.net
Tue Feb 24 19:44:35 CST 2009
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.
More information about the Help-octave
mailing list