@@ -87,20 +87,29 @@ def __init__(self):
8787 self .out = None # output file after fitting
8888 self .data_list = []
8989 self .show ()
90+
9091
9192 def open_file (self ):
9293 """ Open data file """
9394# try:
9495 self .filename = QtWidgets .QFileDialog .getOpenFileName (self )
9596 try :
96- self .file = np . loadtxt ( self .filename [0 ], skiprows = 10 )
97- # except ValueError:
98- # self.file = np.loadtxt(filename[0], skiprows=10 )
97+ if ".csv" in self .filename [ 0 ] or ".txt" in self .filename [0 ]: #if txt or csv, prompt user to enter # of rows to skip
98+ self . skip_rows_window = SkipRowsWindow ()
99+ self . skip_rows_window . skip_rows_signal . connect ( self . open_with_skip_rows_window )
99100 except UnicodeDecodeError :
100101 self .file = read_picoharp_phd (self .filename [0 ])
101102 except :
102103 pass
103104
105+ def open_with_skip_rows_window (self ):
106+ """ Prompts user to enter how many rows to skip """
107+ self .skip_rows = self .skip_rows_window .ui .skip_rows_spinBox .value ()
108+ if ".txt" in self .filename [0 ]:
109+ self .file = np .loadtxt (self .filename [0 ], skiprows = self .skip_rows )
110+ elif ".csv" in self .filename [0 ]:
111+ self .file = np .genfromtxt (self .filename [0 ], skip_header = self .skip_rows , delimiter = "," )
112+
104113 def open_irf_file (self ):
105114 """ Open file with irf - enabled if 'load separate irf' is checled """
106115 filename = QtWidgets .QFileDialog .getOpenFileName (self )
@@ -465,7 +474,6 @@ def export_data(self):
465474 self .data_list = []
466475 file .close ()
467476
468-
469477 def pub_ready_plot_export (self ):
470478 try :
471479 filename = QtWidgets .QFileDialog .getSaveFileName (self ,caption = "Filename with EXTENSION" )
@@ -497,6 +505,28 @@ def close_application(self):
497505 else :
498506 pass
499507
508+ """Skip rows GUI"""
509+ ui_file_path = (base_path / "skip_rows.ui" ).resolve ()
510+ skiprows_WindowTemplate , skiprows_TemplateBaseClass = pg .Qt .loadUiType (ui_file_path )
511+
512+ class SkipRowsWindow (skiprows_TemplateBaseClass ):
513+
514+ skip_rows_signal = QtCore .pyqtSignal () #signal to help with pass info back to MainWindow
515+
516+ def __init__ (self ):
517+ skiprows_TemplateBaseClass .__init__ (self )
518+
519+ # Create the param window
520+ self .ui = skiprows_WindowTemplate ()
521+ self .ui .setupUi (self )
522+ self .ui .done_pushButton .clicked .connect (self .done )
523+ self .setWindowFlag (QtCore .Qt .WindowCloseButtonHint , False )
524+ self .show ()
525+
526+ def done (self ):
527+ self .skip_rows_signal .emit ()
528+ self .close ()
529+
500530def run ():
501531 win = MainWindow ()
502532 QtGui .QApplication .instance ().exec_ ()
0 commit comments