Example #1
0
    def _init_column(self):
        # extract total number of people
        num = 0 if self.main_table.follower is None else len(
            self.main_table.follower)
        # ref column
        for i in range(2):
            col = Column(num,
                         column_type[2],
                         role[1],
                         last_row=column_last_row[3])
            self.container[attach_column_type[i]] = col
        # init column
        self.container[attach_column_type[2]] = Column(
            num,
            column_type[2],
            role[1],
            last_row=column_last_row[3],
            number_format=10)

        self.container[attach_column_type[3]] = Column(
            num, column_type[1], role[2], last_row=column_last_row[3])

        self.container[attach_column_type[4]] = Column(
            num,
            column_type[1],
            role[2],
            last_row=column_last_row[3],
            formula_type=formula_type[2])

        self.container[attach_column_type[5]] = Column(
            num,
            column_type[1],
            role[2],
            last_row=column_last_row[3],
            formula_type=formula_type[2])
Example #2
0
def test2_update_dimension_3():

  temp = Query(dbms=dbms, columns=[Column("1","numeric(1)"),Column("'DESCONOCIDO'","varchar()")])
  cond = Query(
    dbms=dbms,
    sources=[lkp],
    columns=[Column(dbms.count("TEST_ID"), "numeric(3)")]
  )

  statements = "IF (" + cond.code()  + ") = 0 BEGIN\n"
  statements +=  lkp.insert(
      query= temp
  )
  statements += "END\n"

  statements += lkp.update_scd1(
    source = table,
    join_conditions = [["CauBajCod = TEST_ID"]]

  )

  statements += lkp.update_from(
    columns = [lkp.columns["TEST_DESC"]],
    source = table,
    where = [table.columns["CauBajCod"].equals(lkp.columns["TEST_ID"])]
    )
  return statements
Example #3
0
 def set_column_value(self, num, target_value, ref_value, name=None):
     self.name = name
     for k, v in target_value.items():
         if k == target_mapper[2]:
             column = Column(num,
                             column_type[1],
                             self.role,
                             last_row=self._check_last_column(k),
                             number_format=10)
         else:
             column = Column(num,
                             column_type[1],
                             self.role,
                             last_row=self._check_last_column(k))
         column.set_column_value(v)
         self.target[k] = column
     if self.role == role[1]:
         return
     if self.role == role[2]:
         for k, v in ref_value.items():
             if k == ref_mapper[2]:
                 column = Column(num,
                                 column_type[2],
                                 self.role,
                                 last_row=self._check_last_column(k),
                                 number_format=10)
             else:
                 column = Column(num,
                                 column_type[2],
                                 self.role,
                                 last_row=self._check_last_column(k))
             column.set_column_value(v)
             self.ref[k] = column
Example #4
0
 def __init__(self, master=None):
     Frame.__init__(self, master)
     self.master = master
     self.master.title("SportStreamer")
     self.master.configure(background='slate grey')
     self.forum = None
     self.game = None
     self.Sports = Column(self.master, 'SeaGreen3')
     self.Games = Column(self.master, 'SkyBlue3')
     self.Links = Column(self.master, 'forest green')
     self.make_sport_buttons()
Example #5
0
def test_2_update_dimension_2():

    column1 = Column('Name', 'Person', 'varchar(20)', False)
    column2 = Column('Age', 'Person', 'numeric(2)', False)
    table = Table(sql, 'Person', [column1, column2], [column1.name])

    column1 = Column('Person_Name', 'Person', 'varchar(20)', False)
    column2 = Column('Person_Age', 'Person', 'numeric(2)', False)
    lkp = SCDimension1(sql, 'Lkp_Person', [column1, column2], [column1.name])

    return lkp.update_scd1(
        table, [[lkp.columns['Person_Name'].equals(table.columns['Name'])]])
    def convertToTable(self, myNodeObj, columnObj, listObj, length):

        if columnObj == None:
            #root node
            spanning = 0
            for node in myNodeObj.getNodeList():
                newColumn = Column()
                listObj.append(newColumn)
                spanning += self.convertToTable(node, newColumn, listObj,
                                                length)
            return spanning

        else:
            #not root node
            pos = 0
            if myNodeObj.getContent() != "null":
                columnObj.addCell(myNodeObj.getTextElement())
                pos = len(columnObj.getCellsList())
                if myNodeObj.getTextElement().getColspan() == 1:
                    self.updateColumnValues(columnObj,
                                            myNodeObj.getTextElement())

            else:
                textElement = TextElement()
                columnObj.addCell(textElement)
                pos = len(columnObj.getCellsList())

            if len(myNodeObj.getNodeList()) >= 1:
                columnClone = columnObj.clone()
                spanning = 0
                spanning += self.convertToTable(myNodeObj.getNodeElement(0),
                                                columnObj, listObj, length)
                for posCounter in range(1, len(myNodeObj.getNodeList())):
                    newColumn = Column()
                    newColumn.setCellsList(columnClone.getCellsList())
                    listObj.append(newColumn)
                    spanning +=self.convertToTable(myNodeObj.getNodeElement(posCounter),\
                    newColumn, listObj, length)

                textElement = columnObj.getCellsListElement(pos - 1)
                textElement.setColspan(spanning)

                return spanning

            else:
                # no children means that we are at the leaf of a branch
                while len(columnObj.getCellsList()) < length:
                    textElement = TextElement()
                    columnObj.addCell(textElement)
                return 1
Example #7
0
    def _init_req_columns(self, columns):
        """ Creates column objects for each column required by dataframe type. Throws error if a required column is not found in data. """

        new_columns = []

        # looping through required columns
        for col in self.req_columns:
            '''
			try: 
				# getting the variable type of the column 
				unit = self.df[columns[col]['name']].dtype
			except: 
				# exit if the column isn't found in the data 
				print(col, ' column not found in data.')
				sys.exit(1)
			'''
            try:
                # creating new column object
                new_col = Column(columns[col]['name'], columns[col]['type'],
                                 columns[col]['unit'])
                new_columns.append(new_col)
            except:
                print(
                    'Please ensure you have all required columns in config file.'
                )
                sys.exit(1)

        return new_columns
Example #8
0
    def createTable(self):
        con = sqlite3.connect(self.name + '.db')
        con.row_factory = sqlite3.Row
        cur = con.cursor()

        print('1. CREATE FROM DB STUDIO LEVEL')
        print('2. CREATE BY SQL QUERY')
        userChoice = pyip.inputChoice(['1', '2'], ('(1/2)'))
        if userChoice == '1':
            tableName = pyip.inputStr('Table name:')
            # CREATING TABLE OBJECT
            table = Table(tableName)
            columnsAmount = pyip.inputInt('Columns amount:')
            for i in range(columnsAmount):
                columnName = pyip.inputStr('Column name: ')
                columnType = pyip.inputStr('Column type: ')
                # CREATING COLUMN OBJECT
                column = Column(columnName, columnType)
                # ADDING COLUMN OBJECT TO THE COLUMNS PROPERTY IN TABLE OBJECT
                table.columns.append(column)
        # ADDING TABLE TO THE TABLES PROPERTY IN DATABASE OBJECT
        self.tables.append(table)
        # CREATING SQL QUERY
        query = 'CREATE TABLE ' + table.name + ' (\n'
        for i in range(len(table.columns)):
            query += table.columns[i].name + table.columns[i].type + ',\n'
            # HEREEEE

            for i in range(len(table.columns)):
                print(table.columns[i].name, table.columns[i].type,
                      table.columns[i].value)
Example #9
0
def parseLine(line):
    """
	Reads a line and attempts a JSON decode. This function automatically looks for the first instance of an opening bracket '{', 
	and continues until the end of the line. The parsing will respect a given offset, but perhaps that's a bit redundant.
	@param {name: "line", dataType: "string", comment: "Line of input."}
	@return 
	"""
    global args, columnConfig

    try:
        result = json.loads(
            line[line[args.offset:].index('{'):].encode('utf-8'))
    except ValueError:
        return []
    except UnicodeEncodeError:
        return []

    # You didn't specify any columns
    if not args.columns:
        return "No specified columns to print.\n"

    columnList = []
    for column in columnConfig:
        columnList.append(
            Column(column["name"],
                   result[column["name"]].encode('utf-8')
                   if column["name"] in result else "",
                   justify=column["justify"],
                   minWidth=column["minWidth"],
                   maxWidth=column["maxWidth"]))

    return columnList
Example #10
0
def test_2_update_dimension_1():

    column1 = Column('Name', 'Person', 'varchar(20)', False)
    column2 = Column('Age', 'Person', 'numeric(2)', False)
    table = Table(tdms, 'Person', [column1, column2], [column1.name])

    column1 = Column('Person_Name', 'Person', 'varchar(20)', False)
    column2 = Column('Person_Age', 'Person', 'numeric(2)', False)
    lkp = SCDimension1(sql, 'Lkp_Person', [column1, column2], [column1.name])

    query = Query(dbms=sql,
                  sources=[table],
                  columns=[table.columns["Name"], table.columns["Age"]],
                  alias='')

    return lkp.update_scd1(
        query, [[lkp.columns['Person_Name'].equals(table.columns['Name'])]])
Example #11
0
def test_2_update_dimension_1():

    column1 = Column('Name', 'varchar(20)', False)
    column2 = Column('Age', 'numeric(2)', False)
    table = Table(tdms, 'Person', [column1, column2], [column1.name])

    column1 = Column('Person_Name', 'varchar(20)', False)
    column2 = Column('Person_Age', 'numeric(2)', False)
    column_valid = Column('Valid_Record', 'numeric(1)', False)
    column_init_date = Column('Init_Date', 'date', False)
    column_end_date = Column('End_Date', 'date')

    lkp = SCDimension2(sql, 'Lkp_Person', [column1, column2], column_valid,
                       column_init_date, column_end_date, [column1.name])

    query = Query(dbms=sql,
                  sources=[table],
                  columns=[table.columns["Name"], table.columns["Age"]],
                  alias='')

    return lkp.update_scd2(source=query,
                           join_conditions=[[
                               lkp.columns['Person_Name'].equals(
                                   query.columns['Name'])
                           ]])
Example #12
0
 def get_columns(self):
     post_url = self.url + '/posts'
     r = requests.get(post_url)
     soup = BeautifulSoup(r.content)
     for each_column in soup.find_all("a", "avatar-link"):
         #if not collumnBloom.is_element_exist(each_column['href']):
         #    collumnBloom.insert_element(each_column['href'])
         from Column import Column
         yield Column(each_column['href'])
Example #13
0
 def generate_columns(self):
     self.columns = []
     for i in self.table_definition:
         self.columns.append(
             Column(self.cnx, i['COLUMN_NAME'], i['IS_NULLABLE'],
                    i['DATA_TYPE'], i['CHARACTER_MAXIMUM_LENGTH'],
                    i['NUMERIC_PRECISION'], i['NUMERIC_SCALE'],
                    i['COLUMN_TYPE'], i['IS_AUTOINC'], i['IS_UNIQUE'],
                    i['REFERENCED_SCHEMA'], i['REFERENCED_TABLE'],
                    i['REFERENCED_COLUMN'], self.table_name))
Example #14
0
    def _init_opt_columns(self, columns):
        """ Creates column objects for all optional columns. """
        new_columns = []

        # looping through all user defined columns
        for col in columns:
            if col not in self.req_columns:
                unit = self.df[columns[col]['NAME']].dtype
                if unit == 'O':
                    self.preprocess_opt_columns(columns[col]['NAME'])
                new_col = Column(columns[col]['NAME'], columns[col]['TYPE'],
                                 unit)
                new_columns.append(new_col)

        return new_columns
Example #15
0
    def add_col(self, new_col, override=False):
        """ Adds new column object to DataFrame. """
        if type(new_col) == dict:
            new_col = Column(new_col['colname'], new_col['coltype'],
                             new_col['unit'])

        if override:
            # replace column in current DataFrame object with df2 column (if there are overlapping column types)
            self.remove_col(self.get_column_by_type(new_col.get_coltype()))
            self.columns.append(new_col)

        else:
            # only add column object from df2 if there does not exist a column object in current df of same type
            if new_col.get_coltype() not in (self.get_col_types()):
                self.columns.append(new_col)
Example #16
0
def test_2_update_dimension_2():

    column1 = Column('Name', 'Person', 'varchar(20)', False)
    column2 = Column('Age', 'Person', 'numeric(2)', False)
    table = Table(sql, 'Person', [column1, column2], [column1.name])

    column1 = Column('Person_Name', 'Person', 'varchar(20)', False)
    column2 = Column('Person_Age', 'Person', 'numeric(2)', False)
    column_valid = Column('Valid_Record', 'numeric(1)', False)
    column_init_date = Column('Init_Date', 'date', False)
    column_end_date = Column('End_Date', 'date')

    lkp = SCDimension2(sql, 'Lkp_Person', [column1, column2], column_valid,
                       column_init_date, column_end_date, [column1.name])

    return lkp.update_scd2(source=table,
                           join_conditions=[[
                               lkp.columns['Person_Name'].equals(
                                   table.columns['Name'])
                           ]])
Example #17
0
 def add_column(self, name, kind, description=""):
     self._validate_kind(kind)
     column = Column(name, kind, description=description)
     self._columns.append(column)
     return column
Example #18
0
 def get_column(self):
     return Column(width=6,
                   height=19,
                   width_decoration=7,
                   height_decoration=1).render()
Example #19
0
 def add_column(self, column_name, column_type, column_equivalences):
     self.columns.append(
         Column(column_name, column_type, column_equivalences))
Example #20
0
 def __init__(self, app):
     self.app = app
     self.col1 = Column(int(self.app.width/3), self.app)
     self.col2 = Column(int(2*self.app.width/3), self.app)
Example #21
0
 def add_column(self, column_name, column_type):
     self.columns.append(Column(column_name, column_type))
Example #22
0
    rows.append(Row(row_dx, cells[row_dx]))

# print(rows[3].column(4).number().value())

# 3.2) Column -> Cell -> Number
temp_columns = []
for col_dx in range(0, SIZE):
    temp_columns.append([])

for row_idx in range(0, SIZE):
    for col_idx in range(0, SIZE):
        temp_columns[col_idx].append(cells[row_idx][col_idx])

columns = []
for col_idx in range(0, SIZE):
    columns.append(Column(col_idx, temp_columns[col_idx]))
del temp_columns

# print(columns[3].row(4).number().value())

# 4) Square -> Cell -> Number
square_size = int(math.sqrt(SIZE))

# prepare structure: square[x][y]
squares = []
for square_row in range(0, square_size):
    squares.append([])
    for square_col in range(0, square_size):
        squares[square_row].append([])

# fill squares with inner sqauares