Forwarding to the list. ~Josh
Begin forwarded message:
> From: pytables-users-boun...@lists.sourceforge.net
> Date: November 24, 2011 3:33:32 AM GMT+01:00
> To: pytables-users-ow...@lists.sourceforge.net
> Subject: Auto-discard notification
>
> The attached message has been automatically discarded.
> From: "Edward C. Jones" <edcjo...@comcast.net>
> Date: November 24, 2011 3:31:05 AM GMT+01:00
> To: pytables-users@lists.sourceforge.net
> Subject: Rules for appending a tuple to a table
>
>
> I have two tables, sortlist and temptable, each with three columns:
> Float64Col, StringCol(16) and StringCol(16).
>
> alist = list(sortlist[-1])
>
> type(alist[0]) is <type 'numpy.float64'>
> type(alist[1]) is <type 'numpy.string_'>
> type(alist[2]) is <type 'numpy.string_'>
>
> alist prints as [0.40000000000000002, 'abcdefghabcdefgh', '0123456701234567']
>
> with numpy types. I append the list to another table with the same columns:
>
> temptable.append([alist])
>
> list(temptable[-1]) prints as [0.40000000000000002, '', ''] (empty strings)
>
> Where in the PyTables code does this behavior come from? Should an Exception
> have been raised? Is there a general procedure for diagnosing mysterious
> problems in PyTables?
>
> The documentation for Table.append says:
>
> The rows argument may be any object which can be converted to a record
> array compliant with the table structure (otherwise, a ValueError is
> raised). This includes NumPy record arrays, RecArray (depracated) or
> NestedRecArray (deprecated) objects if numarray is available, lists of
> tuples or array records, and a string or Python buffer.
>
> I think more details are needed here.
>
> Now I do things a little differently:
>
> alist = list(sortlist[-1])
> alist[0] = float(alist[0]) # Convert to a Python type.
> temptable.append([alist])
>
> Now list(temptable[-1]) prints as
>
> [0.40000000000000002, 'abcdefghabcdefgh', '0123456701234567']
>
> There is apparently no need to convert the numpy strings into Python
> strings.
>
> If I try the natural thing:
>
> temptable.append([(sortlist[-1]])
>
> I get an useless IndexError: tuple index out of range.
>
>
>
>
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users