A Wednesday 22 August 2007, Geoffrey Zhu escrigué:
> Hi Everyone,
>
> I am wondering how I can persist a whole tuple into a single column
> of a table. If that is possible, it would be very convenient. I have
> a list
>
> l=[ [('A','V',1), 1.2], [('X','O',1), 11]...]
>
> The tuple is the key of each record. I'd like to put it in a single
> column.

One possibility is using nested records to fake a tuple. Look at the 
attached script for an example.  Here is the output of the script:

nested_table:
[(('A', ' ', 0), 0.0) (('B', '!', 1), 1.0) (('C', '"', 2), 4.0)
 (('D', '#', 3), 9.0) (('E', '$', 4), 16.0) (('F', '%', 5), 25.0)
 (('G', '&', 6), 36.0) (('H', "'", 7), 49.0) (('I', '(', 8), 64.0)
 (('J', ')', 9), 81.0)]
nested column:
[('A', ' ', 0) ('B', '!', 1) ('C', '"', 2) ('D', '#', 3) ('E', '$', 4)
 ('F', '%', 5) ('G', '&', 6) ('H', "'", 7) ('I', '(', 8) ('J', ')', 9)]

Bingo! Key found in row # 3 .  Value: 9.0

HTH,


-- 
>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"

Attachment: tuple-in-column.py
Description: application/python

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to