A Friday 25 June 2010 19:18:26 Ben Kraft escrigué:
> Hi all,
>
> I'm having trouble updating pytables rows. Say I have a H5 table
> "h5t" with several rows. According to the manual, it seems I should
> be able to call
>
> h5t[1]['number'] = 3
You are not modifying the table, but just the a numpy object, h5t[1] in
memory. Look at this:
In [6]: type(h5t[1])
Out[6]: <type 'numpy.void'>
In order to modify the value, you have several possibilities:
1.- Use `cols` accessor: h5t.cols.number[1] = 3
2.- Use `modifyRows()` method:
row = h5t[1]
row['number'] = 3
h5t.modifyRows(1, rows=[row])
or...
>
> and the table will set the 'number' record of row 1 to 3 and
> implicitly call row.update. However, the table/row does not update,
> and h5t[1]['number'] returns 0 (or whatever the initial value was).
>
> Regardless, calling
>
> rec = h5t[1]
> rec['number'] = 3
> h5t[1] = [rec]
>
> seems to force the table to update, and now h5t[1]['number'] returns
> the new value.
...this is a third possibility.
>
> Am I missing something? My workaround seems a bit silly, and it's
> probably not guaranteed to work. I'm aware of row.update(), but I
> don't see any way to call it for a specific table index
> (h5t[1].update(), for example).
HTH,
--
Francesc Alted
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Pytables-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pytables-users