Beispiel #1
0
 def _check_fill_title_column(self, column_index):
     '''
     Same as _check_fill_title_row but for columns.
     '''
     # Determine if the whole column is titles
     table_column = TableTranspose(self.table)[column_index]
     prior_column = TableTranspose(self.table)[column_index-1] if column_index > 0 else table_column
     for row_index in range(self.start[0], self.end[0]):
         if is_num_cell(table_column[row_index]) or is_num_cell(prior_column[row_index]):
             return
     # Since we're a title row, stringify the column
     self._stringify_column(column_index)
Beispiel #2
0
 def _check_fill_title_row(self, row_index):
     '''
     Checks the given row to see if it is all titles and fills any blanks cells if that is the
     case.
     '''
     table_row = self.table[row_index]
     # Determine if the whole row is titles
     prior_row = self.table[row_index-1] if row_index > 0 else table_row
     for column_index in range(self.start[1], self.end[1]):
         if is_num_cell(table_row[column_index]) or is_num_cell(prior_row[column_index]):
             return
     # Since we're a title row, stringify the row
     self._stringify_row(row_index)
Beispiel #3
0
 def _check_fill_title_column(self, column_index):
     '''
     Same as _check_fill_title_row but for columns.
     '''
     # Determine if the whole column is titles
     table_column = TableTranspose(self.table)[column_index]
     prior_column = TableTranspose(
         self.table)[column_index - 1] if column_index > 0 else table_column
     for row_index in range(self.start[0], self.end[0]):
         if is_num_cell(table_column[row_index]) or is_num_cell(
                 prior_column[row_index]):
             return
     # Since we're a title row, stringify the column
     self._stringify_column(column_index)
Beispiel #4
0
 def _check_fill_title_row(self, row_index):
     '''
     Checks the given row to see if it is all titles and fills any blanks cells if that is the
     case.
     '''
     table_row = self.table[row_index]
     # Determine if the whole row is titles
     prior_row = self.table[row_index - 1] if row_index > 0 else table_row
     for column_index in range(self.start[1], self.end[1]):
         if is_num_cell(table_row[column_index]) or is_num_cell(
                 prior_row[column_index]):
             return
     # Since we're a title row, stringify the row
     self._stringify_row(row_index)
Beispiel #5
0
    def _check_years(self, cell, prior_year):
        '''
        Helper method which defines the rules for checking for existence of a year indicator. If the
        cell is blank then prior_year is used to determine validity.
        '''
        # Anything outside these values shouldn't auto
        # categorize to strings
        min_year = 1900
        max_year = 2100

        # Empty cells could represent the prior cell's title,
        # but an empty cell before we find a year is not a title
        if is_empty_cell(cell):
            return bool(prior_year)
        # Check if we have a numbered cell between min and max years
        return is_num_cell(cell) and cell > min_year and cell < max_year
Beispiel #6
0
    def _check_years(self, cell, prior_year):
        '''
        Helper method which defines the rules for checking for existence of a year indicator. If the
        cell is blank then prior_year is used to determine validity.
        '''
        # Anything outside these values shouldn't auto
        # categorize to strings
        min_year = 1900
        max_year = 2100

        # Empty cells could represent the prior cell's title,
        # but an empty cell before we find a year is not a title
        if is_empty_cell(cell):
            return bool(prior_year)
        # Check if we have a numbered cell between min and max years
        return is_num_cell(cell) and cell > min_year and cell < max_year