Browse Source

gin commit from nit-ope-de04

New files: 1
sprenger 3 years ago
parent
commit
22a0a6a2c3
1 changed files with 27 additions and 0 deletions
  1. 27 0
      code/convert.py

+ 27 - 0
code/convert.py

@@ -0,0 +1,27 @@
+import load_local_neo_odml_elephant
+
+import os.path
+import neo
+from reachgraspio import reachgraspio
+
+
+def convert(session_path, overwrite=False):
+    rio = reachgraspio.ReachGraspIO(
+        filename=session_path,
+        odml_directory=os.path.dirname(session_path),
+        verbose=False)
+
+    block = rio.read_block(lazy=True)
+
+    if os.path.exists(session_path + '.nix') and not overwrite:
+        raise ValueError(f'Nix file {session_path + ".nix"} already exists.')
+
+    print('Saving to nix')
+    with neo.NixIO(session_path + '.nix', 'ow') as nio:
+        nio.write_block(block)
+
+if __name__ == '__main__':
+    # session = '../datasets/l101210-001'
+    session = '../datasets/i140703-001'
+
+    convert(session, overwrite=True)