Exemplo n.º 1
0
    def deleteColumns(self):
        parent = self.item.parent().text(0)

        if parent == 'Project Tables':
            database = self.project.name
        elif parent == 'Scenario Tables':
            database = '%s%s%s' %(self.project.name, 'scenario', self.project.scenario)            

        projectDBC = createDBC(self.project.db, database)

        tablename = self.item.text(0)
        self.populateVariableDictionary(tablename)
        projectDBC.dbc.open()
        query = QSqlQuery(projectDBC.dbc)

        title = "Delete Dialog - %s" %tablename
        deleteVariablesdia = VariableSelectionDialog(self.variableTypeDictionary, title = title, icon = "modifydata",
                                                     warning = "Note: Select variables to delete.")

        if deleteVariablesdia.exec_():
            deleteVariablesSelected = deleteVariablesdia.selectedVariableListWidget.variables

            for i in deleteVariablesSelected:
                if not query.exec_("""alter table %s drop %s""" %(tablename, i)):
                    raise FileError, query.lastError().text()

        projectDBC.dbc.close()
Exemplo n.º 2
0
    def getSelectedVariables(self, varDict, defaultVariables, title, icon=None, warning=None):
        selDia = VariableSelectionDialog(varDict, defaultVariables, title, icon, warning)

        selVariables = []
        if selDia.exec_():
            selVarCount = selDia.selectedVariableListWidget.count()
            if selVarCount > 0:
                for i in range(selVarCount):
                    selVariables.append(selDia.selectedVariableListWidget.item(i).text())
            return selVariables
Exemplo n.º 3
0
    def housingSelVars(self):
        housingVariablesDialog = VariableSelectionDialog(self.housingVariableDict, self.housingDefaultVariables,
                                                         "PUMS Housing Variable(s) Selection",
                                                         "controlvariables", warning="Note: Select variables to import")

        # Launch a dialogbox to select the housing variables of interest
        if housingVariablesDialog.exec_():
            self.housingVariablesSelectedDummy = True
            self.housingVariablesSelected = housingVariablesDialog.selectedVariableListWidget.variables
        else:
            self.housingVariablesSelectedDummy = False
Exemplo n.º 4
0
    def housingSelVars(self):
        housingVariablesDialog = VariableSelectionDialog(self.housingVariableDict, self.housingDefaultVariables,
                                                         "PUMS Housing Variable(s) Selection",
                                                         "controlvariables", warning="Note: Select variables to import")

        # Launch a dialogbox to select the housing variables of interest
        if housingVariablesDialog.exec_():
            self.housingVariablesSelectedDummy = True
            self.housingVariablesSelected = housingVariablesDialog.selectedVariableListWidget.variables
        else:
            self.housingVariablesSelectedDummy = False
Exemplo n.º 5
0
    def personSelVars(self):
        personVariablesDialog = VariableSelectionDialog(self.personVariableDict, self.personDefaultVariables,
                                                        "PUMS Person Variable(s) Selection",
                                                        "controlvariables", warning="Note: Select variables to import")

        # Launch a dialogbox to select the person variables of interest
        if personVariablesDialog.exec_():
            self.personVariablesSelectedDummy = True
            self.personVariablesSelected = personVariablesDialog.selectedVariableListWidget.variables

        else:
            self.personVariablesSelectedDummy = False
Exemplo n.º 6
0
    def personSelVars(self):
        personVariablesDialog = VariableSelectionDialog(self.personVariableDict, self.personDefaultVariables,
                                                        "PUMS Person Variable(s) Selection",
                                                        "controlvariables", warning="Note: Select variables to import")

        # Launch a dialogbox to select the person variables of interest
        if personVariablesDialog.exec_():
            self.personVariablesSelectedDummy = True
            self.personVariablesSelected = personVariablesDialog.selectedVariableListWidget.variables

        else:
            self.personVariablesSelectedDummy = False
    def getSelectedVariables(self,
                             varDict,
                             defaultVariables,
                             title,
                             icon=None,
                             warning=None):
        selDia = VariableSelectionDialog(varDict, defaultVariables, title,
                                         icon, warning)

        selVariables = []
        if selDia.exec_():
            selVarCount = selDia.selectedVariableListWidget.count()
            if selVarCount > 0:
                for i in range(selVarCount):
                    selVariables.append(
                        selDia.selectedVariableListWidget.item(i).text())
            return selVariables
Exemplo n.º 8
0
    def personVarDicts(self):
        # Reading the list of PUMS person variable names
        if not self.query.exec_("""select variablename, description from """
                                """pumsACSvariablelist where type = 'P'"""):
            raise FileError, self.query.lastError().text()
        else:
            self.personVariableDict = {}
            while (self.query.next()):
                self.personVariableDict['%s'%self.query.value(0).toString()] = '%s'%self.query.value(1).toString()



    def personDefVar(self):
        # Reading the list of PUMS default person variable names
        if not self.query.exec_("""select variablename from pumsACSvariablelist where type = 'P' and defaultvar = 1"""):
            raise FileError, self.query.lastError().text()
        else:
            self.personDefaultVariables = []
            while (self.query.next()):
                self.personDefaultVariables.append(self.query.value(0).toString())


if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    vars = {'a':'first', 'b':'second', 'c':'third', 'd':'fourth'}
    defvars = ['a','b']
    dlg = VariableSelectionDialog(vars, defvars)
    dlg.exec_()
Exemplo n.º 9
0
            if not self.query.exec_(pMasterPUMSTableQuery.query2):
                raise FileError, self.query.lastError().text()


        dummyString = ''
        for i in self.personVariablesSelected:
            dummyString = dummyString + i + ','
            
        dummyString = dummyString[:-1]
        #print dummyString

        #print 'time for creating the raw person table - ', time.time()-ti

        ti = time.time()


        if not self.query.exec_("""create table person_pums select %s from person_raw"""
                                %(dummyString)):
            raise FileError, self.query.lastError().text()

        #print 'time for creating the small person table - ', time.time()-ti


if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    vars = {'a':'first', 'b':'second', 'c':'third', 'd':'fourth'}
    defvars = ['a','b']
    dlg = VariableSelectionDialog(vars, defvars)
    dlg.exec_()