def OnPreview(self,event): self.grid.SetArrayData(np.array(([[],[]]))) filename = self.fctrl.GetPath() delimiter = self.dlm.GetValue() skipr = self.skiprows.GetValue() mps = 100 # max preview size try: data = io.read_txt(filename, delimiter=delimiter, skiprows=skipr) if not data is None: if data.shape[0]>mps and data.shape[1]>mps: self.grid.SetArrayData(data[:mps,:mps]) elif data.shape[0]>mps and data.shape[1]<mps: self.grid.SetArrayData(data[:mps,:]) elif data.shape[0]<mps and data.shape[1]>mps: self.grid.SetArrayData(data[:,:mps]) else: self.grid.SetArrayData(data) infostr = u"Preview from '%s'\nSize: (%g,%g)"%( filename, data.shape[0], data.shape[1]) self.log.write(infostr) else: self.log.write(u"Unable to read data") except Exception as exc: self.log.write(exc)
def GetData(self): filename = self.fctrl.GetPath() delimiter = self.dlm.GetValue() skiprows = self.skiprows.GetValue() try: data = io.read_txt(filename, delimiter=delimiter, skiprows=skiprows) if not data is None: return data else: self.log.write("Unable to read data") except Exception as exc: self.log.write(exc)
def OnPreview(self, event): self.grid.SetArrayData(np.array(([[], []]))) filename = self.fctrl.GetPath() delimiter = self.dlm.GetValue() skipr = self.skiprows.GetValue() mps = 100 # max preview size try: data = io.read_txt(filename, delimiter=delimiter, skiprows=skipr) if not data is None: if data.shape[0] > mps and data.shape[1] > mps: self.grid.SetArrayData(data[:mps, :mps]) elif data.shape[0] > mps and data.shape[1] < mps: self.grid.SetArrayData(data[:mps, :]) elif data.shape[0] < mps and data.shape[1] > mps: self.grid.SetArrayData(data[:, :mps]) else: self.grid.SetArrayData(data) infostr = u"Preview from '%s'\nSize: (%g,%g)" % ( filename, data.shape[0], data.shape[1]) self.log.write(infostr) else: self.log.write(u"Unable to read data") except Exception as exc: self.log.write(exc)