Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 8 additions & 23 deletions NPYViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,10 @@

version="1.28"

def isint(s):
try:
print(int(s))
return True
except ValueError:
return False


def isfloat(s):
try:
print(float(s))
return True
except ValueError:
return False



def openNPY_CLI_noGUI (filename):

if ".npy" in filename:
if Path(filename).suffix.lower() == ".npy":
data = np.load(filename, allow_pickle=True)
else:
data = np.array(pd.read_csv(filename).values.tolist())
Expand Down Expand Up @@ -83,7 +67,8 @@ def saveAs(self):
self, 'Save File', home, 'NPY (*.npy);;CSV(*.csv);;MAT(*.mat)')[0]
# path = QFileDialog.getSaveFileName(
# self, 'Save File', home, 'CSV(*.csv)')[0]
if path != "" and ".csv" in path:
suffix = Path(path).suffix.lower()
if path != "" and suffix == ".csv":
with open((path.replace(".csv", "") + ".csv"), 'w') as stream:
writer = csv.writer(stream)
for row in range(self.tableWidget.rowCount()):
Expand All @@ -109,9 +94,9 @@ def saveAs(self):
if rowdata != []:
OutMatrix.append(rowdata)
OutMatrix = np.array(OutMatrix)
if ".csv" in path:
if suffix == ".npy":
np.save(path, np.array(OutMatrix))
if ".mat" in path:
if suffix == ".mat":
mdic = {"ans": OutMatrix}
print(OutMatrix)
savemat(path, mdic)
Expand All @@ -127,7 +112,7 @@ def openNPY(self):
filename = QFileDialog.getOpenFileName(self, 'Open .NPY file', home, ".NPY files (*.npy);;.CSV files (*.csv)")[
0]
if filename != "":
if ".npy" in filename:
if Path(filename).suffix.lower() == ".npy":
data = np.load(filename, allow_pickle=True)
else:
data = np.array(pd.read_csv(filename).values.tolist())
Expand Down Expand Up @@ -168,7 +153,7 @@ def openNPY(self):

def openNPY_CLI(self,filename):

if ".npy" in filename:
if Path(filename).suffix.lower() == ".npy":
data = np.load(filename, allow_pickle=True)
else:
data = np.array(pd.read_csv(filename).values.tolist())
Expand Down Expand Up @@ -246,7 +231,7 @@ def createMenu(self):
self.statusBar()

ViewTimeSeriesAct= QAction(QIcon(None), 'View as &Time Series', self)
ViewTimeSeriesAct.setShortcut('Ctrl+S')
ViewTimeSeriesAct.setShortcut('Ctrl+T')
ViewTimeSeriesAct.setStatusTip('View as TimeSeries')
ViewTimeSeriesAct.triggered.connect(self.ViewTimeseries)
self.statusBar()
Expand Down