cdbwriter.py 577 B

12345678910111213141516
  1. r"""Module used by vtkCDBWriter"""
  2. from ..tpl import cinemasci
  3. def write(fname, vtktable):
  4. cdb = cinemasci.new("cdb", { "path" : fname})
  5. if not cdb.initialize(dirExistCheck=False):
  6. raise RuntimeError("Failed to initialize dbase")
  7. for row in range(vtktable.GetNumberOfRows()):
  8. entry = {}
  9. for col in range(vtktable.GetNumberOfColumns()):
  10. value = vtktable.GetValue(row, col).ToString()
  11. if value:
  12. entry[vtktable.GetColumnName(col)] = value
  13. cdb.add_entry(entry)
  14. cdb.finalize()
  15. return True