From 3b0c27fcf1ea565999bc216e2bb91750b593f7af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Al=C3=A1n=20Mu=C3=B1oz?= <alan.munoz@ed.ac.uk>
Date: Fri, 17 Mar 2023 16:21:50 +0000
Subject: [PATCH] fix(writer): only create dset when nonexistent

---
 src/agora/io/writer.py | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/agora/io/writer.py b/src/agora/io/writer.py
index bad7c198..71145f2f 100644
--- a/src/agora/io/writer.py
+++ b/src/agora/io/writer.py
@@ -570,14 +570,15 @@ class Writer(BridgeH5):
 
                 # create dataset and write time points as columns
                 tp_path = path + "/timepoint"
-                f.create_dataset(
-                    name=tp_path,
-                    shape=(df.shape[1],),
-                    maxshape=(max_tps,),
-                    dtype="uint16",
-                )
-                tps = list(range(df.shape[1]))
-                f[tp_path][tps] = tps
+                if tp_path not in f:
+                    f.create_dataset(
+                        name=tp_path,
+                        shape=(df.shape[1],),
+                        maxshape=(max_tps,),
+                        dtype="uint16",
+                    )
+                    tps = list(range(df.shape[1]))
+                    f[tp_path][tps] = tps
             else:
                 f[path].attrs["columns"] = df.columns.tolist()
         else:
-- 
GitLab