[PD] Pd+pachube+python

FernandoG dataferx at gmail.com
Sat Dec 11 23:20:53 CET 2010


Thanks guys for yours coments

There was a problem with the datatype (thanks roman and michal), python
script received and sent the data like simbols. To solve the issue i cast
this data to floats in python and now pd patch its working. I think my
solution is really unpolite(sorry iam not a programer) but i can get the
data in to pd numbers boxes. The script is adapted to the specific data
feed, and this data is a vector with tree elements ( ['0',
'2010-12-11T22:11:34.480041Z', '7.6']). First I delate  second
elemnt(2010-12-11T22:11:34.480041Z) because i dont know how to cast it and i
dont need the date. There is the python code:

# to receive data
import urllib2
# to send on with OpenSoundControl, OSC
from simpleOSC import *
import time

initOSCClient('127.0.0.1', 57110)
while 1:
  data=urllib2.urlopen('
http://api.pachube.com/v2/feeds/2791.csv?key=hereyourownkey') # this data
feed has tree diferents values
  for l in data:
    d = l.strip().split(",", 2)
    del d[1] #this is because this variable was the date and i dont know how
to cast it
    var = map(lambda x: float(x), d)
    print var
    sendOSCMsg('/test/num',var) #
    del var[0]
    sendOSCMsg('/test/val',var)
    time.sleep(5) # wait here some secs

the pd patch


#N canvas 822 23 450 476 10;
#X declare -lib mrpeach;
#X obj -103 27 import mrpeach;
#X obj -106 114 unpackOSC;
#X floatatom -105 279 0 0 0 0 - - -;
#X obj -100 150 routeOSC /test;
#X floatatom -36 283 5 0 0 0 - - -;
#X obj -105 68 udpreceive 57110;
#X floatatom 22 292 5 0 0 0 - - -;
#X obj -55 205 routeOSC /val /num;
#X obj -98 321 osc~ 440;
#X obj -85 371 dac~;
#X connect 1 0 3 0;
#X connect 2 0 8 0;
#X connect 3 0 7 0;
#X connect 5 0 1 0;
#X connect 7 0 2 0;
#X connect 7 1 4 0;
#X connect 7 2 6 0;
#X connect 8 0 9 0;
#X connect 8 0 9 1;


2010/12/11 mark edward grimm <mgrimm at syr.edu>

> wow... looks like a lot of platforms are supported.
> http://community.pachube.com/software_hardware
>
> maybe a native pd external or pyext external would be nice....
>
> anyway... i would like to know if you get this working..,
>
> thanks!
> mark
>
>
>
> On Sat, Dec 11, 2010 at 3:26 PM, Michal Seta <mis at artengine.ca> wrote:
> > On Sun, Dec 5, 2010 at 8:26 PM, FernandoG <dataferx at gmail.com> wrote:
> >> Data can not get in a number box object, this error mesagge is diplayed
> in
> >> console:   error: gatom: no method for '1'
> >
> > I don't know simpleOSC but this code/description looks like your '1',
> > by the time it is received by Pd is untyped(?), and there fore
> > numberbox does not know how to deal with it.   Did you try [print]?
> > You may want to pass that output through [sprintf %i] or something
> > similar (perhaps just [trigger float] will do?) to 'cast' it into
> > proper datatype.  I don't have pd handy to test but this should set
> > you on the right track.
> >
> > ./MiS
> >
> > _______________________________________________
> > Pd-list at iem.at mailing list
> > UNSUBSCRIBE and account-management ->
> http://lists.puredata.info/listinfo/pd-list
> >
>
>
>
> --
> ____________________
> mark edward grimm | m.f.a
> IT macintosh engineer | adjunct
> syracuse u. | vpa foundations | timearts
> mgrimm at syr.edu | 315.378.2136
> _________________________________
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20101211/18fbaec5/attachment.htm>


More information about the Pd-list mailing list