Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import tables
  2.  
  3. class Test(tables.IsDescription):
  4.     word1 = tables.StringCol(50, pos=0)
  5.     word2 = tables.StringCol(50, pos=1)
  6.     weight = tables.Int32Col(pos=2)
  7.  
  8. h5file = tables.openFile('derp.h5', mode='w')
  9. table = h5file.createTable(h5file.root, 'derp_table', Test, 'derp')
  10.  
  11. r = table.row
  12. words = [("hello", "salut"), ("numa", "yay"), ("full", "open")]
  13. for w in words:
  14.     r['word1'] = w[0]
  15.     r['word2'] = w[1]
  16.     r['weight'] = 0
  17.     r.append()
  18. table.flush()
  19.  
  20. results_query1 = [r.nrow for r in table.where('word1 == "hello"')]
  21. print table.readCoordinates(results_query1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement