Francesc

Many thanks for your quick answer, I made a test without Psyco and it
works, but the problem that I have, psyco is a vital part of my
project.

I run the same test, but iterating over all the rows and I making
inside the loop an explicit condition and it works with psyco

Are there some alternative way to iterate over some rows in a table
that satisface a condition and the posibility of modify the table
values?

regards

German






> Date: Wed, 9 Jun 2010 11:40:38 +0100
> From: German Ocampo <geroca...@gmail.com>
> Subject: [Pytables-users] help with an error when I tried to modify a
>        table
> To: pytables-users@lists.sourceforge.net
> Message-ID:
>        <aanlktikgp1gcwgczpkcgchdhcyk2yl37hi5delb6v...@mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hello
>
> Im newbie in pytables and I have a question regarding to an error
> message. I writing a program which basically read a text file to a
> pytable  and then I want to modify one field in the table according to
> a condition related to another field. the program is very simple and
> I'm getting the following error:
>
>  File "D:\python\prod_tests\src\test_receivers.py", line 54, in <module>
>    check_receivers(path_r,1)
>  File "D:\python\prod_tests\src\test_receivers.py", line 45, in 
> check_receivers
>    for row in ro_detector.where('completo <= 20000'):
>  File "C:\Python26\lib\site-packages\tables\table.py", line 1210, in where
>    return self._where(condition, condvars, start, stop, step)
>  File "C:\Python26\lib\site-packages\tables\table.py", line 1226, in _where
>    condvars = self._requiredExprVars(condition, condvars, depth=3)
>  File "C:\Python26\lib\site-packages\tables\table.py", line 977, in
> _requiredExprVars
>    user_locals = user_frame.f_locals
>  File "C:\Python26\lib\site-packages\psyco\support.py", line 124, in
> __getattr__
>    raise AttributeError, ("local variables of functions run by Psyco "
> AttributeError: local variables of functions run by Psyco cannot be
> accessed in any way, sorry
> Closing remaining open files: temp.h5... done
>
> I got the same error in Windows xp as well as  Ubuntu 10.4.
>
> Could you please help me with that?
>
> Regards
>
> German
>
> the source code is the following
>
> import os
> from tables import *
> import numpy as np
>
> def check_receivers(path_r,espaciamiento):
>
>
>    class Detector(IsDescription):
>        completo = FloatCol()
>        punto    = FloatCol()
>        fecha    = FloatCol()
>
>    file = open(path_r,"r")
>
>    filename = "temp.h5"
>    hIndex1file = openFile(filename, mode = "w", title = "Test file")
>
>    group_detector   = hIndex1file.createGroup("/", 'detector',
> 'Detector information')
>    table_detector = hIndex1file.createTable(group_detector,
> 'preplot',Detector, "hh")
>    row_detector   = table_detector.row
>
>    while 1:
>        line = file.readline()
>        if len(line)>12:
>            row_detector['completo']=
> float(float(line[1:11])*1000000+float(line[11:21]))
>            row_detector['punto']   = float(line[11:21])
>            row_detector['fecha']   = float(0)
>            row_detector.append()
>        if not line:
>            break
>        pass # do something
>    file.close()
>
>    hIndex1file.close()
>
>    filename = "temp.h5"
>    hIndex1file = openFile(filename, mode = "a", title = "Test file")
>    ro_detector= hIndex1file.root.detector.preplot
>    fecha_ant=0
>
>    for row in ro_detector.where('completo <= 20000'):
>        row['fecha'] = 2
>        row.update()
>    hIndex1file.close()
>
> if __name__=="__main__":
>    import psyco
>    psyco.full()
>    path_r="D:/python/prod_tests/src/data/sourcesps_sim_select_s1143_r1117.r"
>    check_receivers(path_r,1)
>
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 9 Jun 2010 13:11:09 +0200
> From: Francesc Alted <fal...@pytables.org>
> Subject: Re: [Pytables-users] help with an error when I tried to
>        modify a        table
> To: pytables-users@lists.sourceforge.net
> Message-ID: <201006091311.09422.fal...@pytables.org>
> Content-Type: Text/Plain;  charset="iso-8859-1"
>
> Hola German,
>
> A Wednesday 09 June 2010 12:40:38 German Ocampo escrigu?:
>> Hello
>>
>> Im newbie in pytables and I have a question regarding to an error
>> message. I writing a program which basically read a text file to a
>> pytable  and then I want to modify one field in the table according to
>> a condition related to another field. the program is very simple and
>> I'm getting the following error:
>>
>>   File "D:\python\prod_tests\src\test_receivers.py", line 54, in <module>
>>     check_receivers(path_r,1)
>>   File "D:\python\prod_tests\src\test_receivers.py", line 45, in
>>  check_receivers for row in ro_detector.where('completo <= 20000'):
>>   File "C:\Python26\lib\site-packages\tables\table.py", line 1210, in where
>>     return self._where(condition, condvars, start, stop, step)
>>   File "C:\Python26\lib\site-packages\tables\table.py", line 1226, in
>>  _where condvars = self._requiredExprVars(condition, condvars, depth=3)
>>  File "C:\Python26\lib\site-packages\tables\table.py", line 977, in
>>  _requiredExprVars
>>     user_locals = user_frame.f_locals
>>   File "C:\Python26\lib\site-packages\psyco\support.py", line 124, in
>> __getattr__
>>     raise AttributeError, ("local variables of functions run by Psyco "
>> AttributeError: local variables of functions run by Psyco cannot be
>> accessed in any way, sorry
>> Closing remaining open files: temp.h5... done
>>
>> I got the same error in Windows xp as well as  Ubuntu 10.4.
>
> Well, by looking into the error, it seems that psyco is the responsible of it.
> Just disable psyco.  Do you really need psyco for doing this?  We all should
> always remember the mantra: "premature optimization is the root of all evil".
>
> --
> Francesc Alted
>
>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 9 Jun 2010 17:06:03 +0200
> From: Francesc Alted <fal...@pytables.org>
> Subject: Re: [Pytables-users] PyTables 2.2rc1 released
> To: pytables-users@lists.sourceforge.net
> Message-ID: <201006091706.03212.fal...@pytables.org>
> Content-Type: Text/Plain;  charset="iso-8859-15"
>
> A Tuesday 08 June 2010 19:29:16 Ivan Vilata i Balaguer escrigu?:
>> Francesc Alted (2010-06-07 14:49:34 +0200) wrote:
>> > Could you please run the attached script (blosc_bigendian.py) and send
>> > the resulting file back to me?  I plan to add this file in the test
>> > suite.  Also, please send me the output of ``ptdump -vd`` against my
>> > attached little-endian file (blosc_bigendian.h5).  You will need to
>> > update your PyTables trunk local repository in your big-endian platform
>> > before doing this, of course.
>>
>> I'm attaching the result of dumping your attached HDF5 file and the new
>>  HDF5 file of the same name which is created by the script.  I've used
>>  PyTables SVN trunk r4464 under the G4.
>
> Great, it works as intended.  Thanks!
>
> --
> Francesc Alted
>
>
>
> ------------------------------
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
>
> ------------------------------
>
> _______________________________________________
> Pytables-users mailing list
> Pytables-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pytables-users
>
>
> End of Pytables-users Digest, Vol 49, Issue 4
> *********************************************
>

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to