Reputation: 5748
I am using Python 2.7, and trying to perform a PyTables query:
#Here the condition
selectedIndex = [1,6,7,9]
condition = 'IndexColumn in selectedIndex'
#here the query
for x1 in tab.where(condition,selectedIndex):
...
...
...
And I am getting:
TypeError: argument of type 'VariableNode' is not iterable
From the documentation about pytables, I am trying to use this:
Table.where(condition, condvars=None, start=None, stop=None, step=None)
And that:
condition = 'col1 == "AAAA"'
for record in table.where(condition): # TypeError in Python3
#do something with "record"
What I am doing wrong?
Upvotes: 0
Views: 139
Reputation: 1150
I think the correct way to do the in-kernel query using a string argument in your case would be:
conditon="(IndexColumn==1)|(IndexColumn==6)|(IndexColumn==7)|(IndexColumn==9)"
and IndexColumn needs to be the actual name of the column as specfied in your IsDescription class. I believe the python condition "a in b" is not valid for Pytablles queries
EDIT concerning your comment:
"".join(["(IndexColumn==%i)|"%j for j in selectedIndex])[:-1]
should give you the correct string for the query.
Upvotes: 1