From 01b109a099a7e922357a8ed8bf36257b61fb493b Mon Sep 17 00:00:00 2001 From: Michael Dryden Date: Wed, 7 May 2014 12:33:33 -0400 Subject: [PATCH] Supports text output. --- dstatInterface/interface/dstatInterface.glade | 6 +++--- dstatInterface/interface/save.py | 16 ++++++++++++++-- dstatInterface/interface_test.py | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/dstatInterface/interface/dstatInterface.glade b/dstatInterface/interface/dstatInterface.glade index e56f064..8c0a51b 100644 --- a/dstatInterface/interface/dstatInterface.glade +++ b/dstatInterface/interface/dstatInterface.glade @@ -137,13 +137,13 @@ - - Save data as NPY + + Save current data... True False image2 False - + diff --git a/dstatInterface/interface/save.py b/dstatInterface/interface/save.py index 0e83f2f..4789d40 100644 --- a/dstatInterface/interface/save.py +++ b/dstatInterface/interface/save.py @@ -12,7 +12,7 @@ class npSave: self.filters[0].set_name("NumPy binary (.npy)") self.filters[0].add_pattern("*.npy") self.filters.append(gtk.FileFilter()) - self.filters[1].set_name("Whitespace separated text (.txt)") + self.filters[1].set_name("Space separated text (.txt)") self.filters[1].add_pattern("*.txt") self.fcd.set_do_overwrite_confirmation(True) @@ -28,10 +28,22 @@ class npSave: if filter_selection.endswith("(.npy)"): self.npy() + elif filter_selection.endswith("(.txt)"): + self.text() self.fcd.destroy() def npy(self): self.data = np.array(self.exp.data) - np.save(self.path, self.data) + np.save(self.path, self.data()) + + def text(self): + if not self.path.endswith(".txt"): + self.path += ".txt" + + self.data = np.array(self.exp.data) + header = "" + for i in self.exp.commands: + header += i + np.savetxt(self.path, self.data.transpose(), header=header, newline='\n') diff --git a/dstatInterface/interface_test.py b/dstatInterface/interface_test.py index 277b7c4..08d2d81 100644 --- a/dstatInterface/interface_test.py +++ b/dstatInterface/interface_test.py @@ -298,7 +298,7 @@ class main: self.databuffer.insert_at_cursor("\n") self.spinner.stop() - def on_file_save_npy_activate(self, menuitem, data=None): + def on_file_save_exp_activate(self, menuitem, data=None): if self.current_exp: self.save = save.npSave(self.current_exp) -- GitLab