【发布时间】:2018-11-16 03:59:29
【问题描述】:
我有一张桌子:
h5file=open_file("ex.h5", "w")
class ex(IsDescription):
A=StringCol(5, pos=0)
B=StringCol(5, pos=1)
C=StringCol(5, pos=2)
table=h5file.create_table('/', 'table', ex, "Passing string as column name")
table=h5file.root.table
rows=[
('abc', 'bcd', 'dse'),
('der', 'fre', 'swr'),
('xsd', 'weq', 'rty')
]
table.append(rows)
table.flush()
我正在尝试按以下方式查询:
find='swr'
creteria='B'
if creteria=='B':
condition='B'
else:
condition='C'
value=[x['A'] for x in table.where("""condition==find""")]
print(value)
返回:
ValueError:没有列参与条件condition==find
有没有办法在上面的查询中使用条件作为列名? 提前致谢。
【问题讨论】:
标签: pytables