def submit_change(self):
        sender = self.sender()
        self.cbindlned = {
            'column_1': self.lnedColumn1.text().strip(),
            'column_2': self.lnedColumn2.text().strip()
        }
        self.cbindini = ini.InputHandler(name='cbind',
                                         lnedentry=self.cbindlned)
        self.facade.input_register(self.cbindini)
        self.facade.create_log_record('cbind')
        self._log = self.facade._tablelog['cbind']

        if self.previous_click is True:
            self.viewEdit = view.PandasTableModelEdit(None)
        else:
            pass

        try:
            self.cbindtable = hlp.cbind(self.facade._data,
                                        self.cbindlned['column_1'],
                                        self.cbindlned['column_2'])
        except Exception as e:
            print(str(e))
            self.error.showMessage('Could combine column values: ' + str(e))

        hlp.write_column_to_log(self.cbindlned, self._log, 'cbind')

        if sender is self.btnPreview:
            self.viewEdit.set_data(self.cbindtable)
            self.preview.tabviewPreview.setModel(self.viewEdit)
            self.preview.show()
        elif sender is self.btnSaveClose:
            self.facade._data = self.cbindtable
            self.update_data.emit('update')
            self.close()
Esempio n. 2
0
        def __init__(self, parent=None):
            super().__init__(parent)
            self.setupUi(self)

            # Facade set up
            self.facade = face.Facade()
            self.facade.input_register(meta_handle_1_count)
            self.facade.meta_verify()
            self.facade.input_register(file_handle_split_columns)
            self.facade.load_data()

            self.previous_click = False
            # Place holders for user inputs
            self.splitcolumnlned = {}

            # Place holder: Data Model/ Data model view
            self.splitcolumnmodel = None
            self.viewEdit = view.PandasTableModelEdit(None)
            # Placeholders: Data tables
            self.splitcolumntable = None

            # Actions
            self.btnPreview.clicked.connect(self.submit_change)
            self.btnSaveClose.clicked.connect(self.submit_change)
            self.btnCancel.clicked.connect(self.close)

            # Update boxes/preview box
            self.message = QtGui.QMessageBox
            self.error = QtGui.QErrorMessage()
            self.preview = tprev.TablePreview()
Esempio n. 3
0
    def submit_change(self):
        sender = self.sender()
        self.replacevaluelned = {
            'column_name': self.lnedColumnname.text().strip(),
            'value_from': self.lnedFrom.text(),
            'value_to': self.lnedTo.text().strip(),
            'all_columns': self.ckAllcolumns.isChecked()
        }
        self.replacevalueini = ini.InputHandler(
            name='replacevalue', lnedentry=self.replacevaluelned)
        self.facade.input_register(self.replacevalueini)
        self.facade.create_log_record('replacevalue')
        self._log = self.facade._tablelog['replacevalue']

        if self.previous_click is True:
            self.viewEdit = view.PandasTableModelEdit(None)
        else:
            pass

        try:
            if self.replacevaluelned['all_columns'] is True:
                self.replacevaluetable = self.facade._data.replace({
                    self.replacevaluelned['value_from']:
                    self.replacevaluelned['value_to']
                })
            else:
                columntochange = self.replacevaluelned['column_name']
                assert (columntochange is not '') is True
                self.replacevaluetable = self.facade._data.replace({
                    columntochange: {
                        self.replacevaluelned['value_from']:
                        self.replacevaluelned['value_to']
                    }
                })
            self.previous_click = True
        except Exception as e:
            print(str(e))
            self.error.showMessage('Could not replace values: ' + str(e))

        hlp.write_column_to_log(self.replacevaluelned, self._log,
                                'replacevalue')

        if sender is self.btnPreview:
            self.viewEdit.set_data(self.replacevaluetable)
            self.preview.tabviewPreview.setModel(self.viewEdit)
            self.preview.show()
        elif sender is self.btnSaveClose:
            self.facade._data = self.replacevaluetable
            self.update_data.emit('replace_mod')
            self.close()
Esempio n. 4
0
    def submit_change(self):
        sender = self.sender()
        self.covarlned['columns'] = hlp.string_to_list(self.lnedColumns.text())

        self.covarini = ini.InputHandler(name='covarinfo',
                                         tablename='covartable',
                                         lnedentry=self.covarlned)

        self.facade.input_register(self.covarini)
        self.facade.create_log_record('covartable')
        self._log = self.facade._tablelog['covartable']

        if self.covarlned['columns'][0] == '':
            print('in pass')
            pass
        else:
            try:
                self.facade._data[self.covarlned['columns']]
            except Exception as e:
                print(str(e))
                self._log.debug(str(e))
                self.error.showMessage(
                    'Column names not valid: Check spacing ' + 'and headers.')
                raise ValueError('Column names are incorrect')

        try:
            self.covardata = ddf.DictionaryDataframe(
                self.facade._data,
                self.covarlned['columns']).convert_records()
        except Exception as e:
            print(str(e))
            self._log.debug(str(e))
            self.error.showMessage('Could not concatenate columns')
            raise TypeError('Could not concatenate columns')

        self.facade.push_tables['covariates'] = self.covardata

        if sender is self.btnColumns:
            self.message.about(self, 'Status', 'Columns recorded')
        elif sender is self.btnPreview:
            self.covarmodel = views.PandasTableModelEdit(self.covardata)
            self.preview.tabviewPreview.setModel(self.covarmodel)
            self.preview.show()
        elif sender is self.btnSaveClose:
            hlp.write_column_to_log(self.covarlned, self._log, 'covartable')
            self.close()
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setupUi(self)

        self.previous_click = False
        # Place holders for user inputs
        self.cbindlned = {}
        # Place holder: Data Model/ Data model view
        self.cbindmodel = None
        self.viewEdit = view.PandasTableModelEdit(None)
        # Placeholders: Data tables
        self.cbindtable = None
        # Actions
        self.btnPreview.clicked.connect(self.submit_change)
        self.btnSaveClose.clicked.connect(self.submit_change)
        self.btnCancel.clicked.connect(self.close)
        # Update boxes/preview box
        self.message = QtGui.QMessageBox
        self.error = QtGui.QErrorMessage()
        self.preview = tprev.TablePreview()
Esempio n. 6
0
        def submit_change(self):
            sender = self.sender()
            self.splitcolumnlned = {
                'column_name': self.lnedColumnname.text().strip(),
                'split_column_by': self.lnedSplitcolumnby.text()
            }
            print('split inputs: ', self.splitcolumnlned)
            self.splitcolumnini = ini.InputHandler(
                name='splitcolumn', lnedentry=self.splitcolumnlned)
            self.facade.input_register(self.splitcolumnini)
            self.facade.create_log_record('splitcolumn')
            self._log = self.facade._tablelog['splitcolumn']

            if self.previous_click is True:
                self.viewEdit = view.PandasTableModelEdit(None)
            else:
                pass

            try:
                self.splitcolumntable = hlp.split_column(
                    self.facade._data, self.splitcolumnlned['column_name'],
                    self.splitcolumnlned['split_column_by'])
                self.previous_click = True
            except Exception as e:
                print(str(e))
                self.error.showMessage('Could split column: ' + str(e))

            hlp.write_column_to_log(self.splitcolumnlned, self._log,
                                    'splitcolumn')

            if sender is self.btnPreview:
                self.viewEdit.set_data(self.splitcolumntable)
                self.preview.tabviewPreview.setModel(self.viewEdit)
                self.preview.show()
            elif sender is self.btnSaveClose:
                self.facade._data = self.splitcolumntable
                self.update_data.emit('update')
                self.close()
Esempio n. 7
0
    def __init__(self, parent=None):
        super().__init__(parent)
        # attributes
        self.setupUi(self)
        self.facade = face.Facade()
        self._log = None
        self.dsite = sitelogic.SiteDialog()
        self.dsession = sesslogic.SessionDialog()
        self.dmain = mainlogic.MainDialog()
        self.dtaxa = taxalogic.TaxaDialog()
        self.dtime = timelogic.TimeDialog()
        self.draw = rawlogic.ObsDialog()
        self.dcovar = covarlogic.CovarDialog()
        self.dclimatesite = climsitelogic.ClimateSite()
        self.dclimatesession = sesslogic.SessionDialog()
        self.dwidetolong = widetolonglogic.WidetoLongDialog()
        self.dsplitcolumn = splitcolumnlogic.SplitColumnDialog()
        self.dreplacevalue = replacelogic.ReplaceValueDialog()
        self.dcbind = cbindlogic.CbindDialog()
        self.data_model = view.PandasTableModelEdit(None)
        self.data_model.log_change.connect(self.write_to_log)
        self.change_count = 0

        # Actions
        self.actionUndo.triggered.connect(self.undo_data_mod)
        self.actionCombine_Columns.triggered.connect(self.cbind_display)
        self.actionReplace.triggered.connect(self.replace_value_display)
        self.actionConvert_Wide_to_Long.triggered.connect(
            self.wide_to_long_display)
        self.actionSplit_Column_By.triggered.connect(self.split_column_display)
        self.actionSiteTable.triggered.connect(self.site_display)
        self.actionStart_Session.triggered.connect(self.session_display)
        self.actionEnd_Session.triggered.connect(self.end_session)
        self.actionMainTable.triggered.connect(self.main_display)
        self.actionTaxaTable.triggered.connect(self.taxa_display)
        self.actionTimeFormat.triggered.connect(self.time_display)
        self.actionRawTable.triggered.connect(self.obs_display)
        self.actionCovariates.triggered.connect(self.covar_display)
        self.actionCommit.triggered.connect(self.commit_data)
        self.actionClimateSiteTable.triggered.connect(
            self.climate_site_display)
        self.actionNew_Climate.triggered.connect(self.climate_session_display)

        self.mdiArea.addSubWindow(self.subwindow_2)
        self.mdiArea.addSubWindow(self.subwindow_1)

        # Custom Signals
        self.dsite.site_unlocks.connect(self.site_complete_enable)
        self.dwidetolong.update_data.connect(self.update_data_model)
        self.dsplitcolumn.update_data.connect(self.update_data_model)
        self.dreplacevalue.update_data.connect(self.update_data_model)
        self.dcbind.update_data.connect(self.update_data_model)
        self.dclimatesite.climatesite_unlocks.connect(
            self.climate_site_complete_enabled)
        self.dsession.raw_data_model.connect(self.update_data_model)
        self.dclimatesession.raw_data_model.connect(self.update_data_model)

        # Dialog boxes for user feedback
        self.error = QtGui.QErrorMessage()
        self.message = QtGui.QMessageBox

        metadf = read_csv(metapath, encoding='iso-8859-11')
        metamodel = view.PandasTableModel(
            metadf[['global_id', 'lter', 'title', 'site_metadata',
                    'temp_int']])

        self.tblViewMeta.setModel(metamodel)
        self.tblViewMeta.resizeColumnsToContents()
        self.tblViewRaw.horizontalHeader().sectionDoubleClicked.connect(
            self.changeHorizontalHeader)
        self.tblViewRaw.resizeColumnsToContents()
Esempio n. 8
0
 def update_data_view(self):
     self.data_model = view.PandasTableModelEdit(None)
     self.data_model.set_data(self.facade._data)
     self.tblViewRaw.setModel(self.data_model)