• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python xlrd.colname函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中xlrd.colname函数的典型用法代码示例。如果您正苦于以下问题:Python colname函数的具体用法?Python colname怎么用?Python colname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了colname函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: show_row

 def show_row(bk, sh, rowx, colrange, printit):
     if printit: print
     if bk.formatting_info:
         for colx, ty, val, cxfx in get_row_data(bk, sh, rowx, colrange):
             if printit:
                 print "cell %s%d: type=%d, data: %r, xfx: %s" \
                     % (xlrd.colname(colx), rowx+1, ty, val, cxfx)
     else:
         for colx, ty, val, _unused in get_row_data(bk, sh, rowx, colrange):
             if printit:
                 print "cell %s%d: type=%d, data: %r" % (xlrd.colname(colx), rowx+1, ty, val)
开发者ID:W00D00,项目名称:xlrd,代码行数:11,代码来源:runxlrd.py


示例2: _retrieve_subindex_observations

    def _retrieve_subindex_observations(self, structure_obs_sheet, subindex_name, subindex_scaled_column, sheet_year):
        self._log.debug(
            "\t\tRetrieving subindex %s observations in sheet %s..." % (subindex_name, structure_obs_sheet.name))
        year_column = get_column_number(
            self._config_get("STRUCTURE_OBSERVATIONS", "OBSERVATION_YEAR_COLUMN", sheet_year))
        iso3_column = get_column_number(
            self._config_get("STRUCTURE_OBSERVATIONS", "OBSERVATION_ISO3_COLUMN", sheet_year))
        check_column = get_column_number(
            self._config_get("STRUCTURE_OBSERVATIONS", "OBSERVATION_CHECK_COLUMN", sheet_year))
        observation_start_row = self._config_getint("STRUCTURE_OBSERVATIONS", "OBSERVATION_START_ROW", sheet_year)
        empty_row_error_cache = {}

        try:
            subindex_rank_column = self._find_rank_column(structure_obs_sheet, subindex_name, sheet_year)
            if not subindex_rank_column:
                self._log.warn("No rank column found for SUBINDEX '%s' while parsing %s" % (
                    subindex_name, structure_obs_sheet.name))
            indicator = self._indicator_repo.find_indicator_by_code(subindex_name, 'SUBINDEX')
            for row_number in range(observation_start_row, structure_obs_sheet.nrows):  # Per country
                if not structure_obs_sheet.cell(row_number, check_column).value or row_number in empty_row_error_cache:
                    if row_number not in empty_row_error_cache:
                        self._log.debug(
                            "Skipping row while parsing %s[%s] (did not detect value on check column, additional errors regarding this row will be omitted)" % (
                                structure_obs_sheet.name, row_number))
                    empty_row_error_cache[row_number] = True
                    continue
                try:
                    year = int(structure_obs_sheet.cell(row_number, year_column).value)
                    iso3 = structure_obs_sheet.cell(row_number, iso3_column).value
                    area = self._area_repo.find_by_iso3(iso3)
                    value = structure_obs_sheet.cell(row_number, subindex_scaled_column).value
                    rank = structure_obs_sheet.cell(row_number,
                                                    subindex_rank_column).value if subindex_rank_column else None
                    excel_observation = ExcelObservation(iso3=iso3, indicator_code=indicator.indicator, year=year,
                                                         rank=rank, value=value)
                    if [t for t in self._excel_structure_observations if
                        t[0].year == year and t[1].iso3 == iso3 and t[2].indicator == indicator.indicator]:
                        self._log.warn("Ignoring duplicate observations for SUBINDEX %s while parsing %s [%s]" % (
                            indicator.indicator, structure_obs_sheet.name,
                            colname(subindex_scaled_column)))
                        # Will not continue parsing, we could check this also at the beginning if we extract the
                        # year from the sheet name
                        return
                    else:
                        self._excel_structure_observations.append((excel_observation, area, indicator))
                except AreaRepositoryError:
                    self._log.error("No area with code %s for indicator %s while parsing %s" % (
                        iso3, indicator.indicator, structure_obs_sheet.name))
                except:
                    self._log.error("Unexpected error parsing %s[%s]" % (structure_obs_sheet.name, row_number))
        except IndicatorRepositoryError:
            self._log.error(
                "No SUBINDEX '%s' indicator found while parsing %s [%s]" % (
                    subindex_name, structure_obs_sheet.name, colname(subindex_scaled_column)))
开发者ID:TheWebFoundation,项目名称:odb-parser,代码行数:54,代码来源:observation_parser.py


示例3: show_row

 def show_row(bk, sh, rowx, colrange, printit):
     if bk.ragged_rows:
         colrange = range(sh.row_len(rowx))
     if not colrange: return
     if printit: print()
     if bk.formatting_info:
         for colx, ty, val, cxfx in get_row_data(bk, sh, rowx, colrange):
             if printit:
                 print("cell %s%d: type=%d, data: %r, xfx: %s"
                     % (xlrd.colname(colx), rowx+1, ty, val, cxfx))
     else:
         for colx, ty, val, _unused in get_row_data(bk, sh, rowx, colrange):
             if printit:
                 print("cell %s%d: type=%d, data: %r" % (xlrd.colname(colx), rowx+1, ty, val))
开发者ID:ClayMason,项目名称:BlackrockFBP,代码行数:14,代码来源:runxlrd.py


示例4: compareFields

def compareFields(tabletIID, tabletData, paperData, IIDIndex):
    ws_paper.write(IIDIndex, 0, mapIID(tabletIID))
    ws_tablet.write(IIDIndex, 0, tabletIID)
    ws_diff.write(IIDIndex, 0, tabletIID[2:])
    startTime = None
    varIndex = 1
    for field in sorted(tabletData.keys()):
        name = field[4:]
        if name == keywords['startTime']:
            startTime = datetime.datetime.strptime(tabletData[field][0], "%I:%M:%S %p")
        if IIDIndex == 1:
            ws_diff.write(0, varIndex, name)
            ws_paper.write(0, varIndex, name)
            ws_tablet.write(0, varIndex, name)
        if name[:8] == keywords['runTime']:
            if tabletData[field][0] == '':
                runtime = 'n.a.'
            else:
                timestamp = datetime.datetime.strptime(tabletData[field][0], "%I:%M:%S %p")
                runtime = (timestamp - startTime).seconds / 60.0
            ws_paper.write(IIDIndex, varIndex, runtime)
            ws_tablet.write(IIDIndex, varIndex, runtime)
            ws_diff.write(IIDIndex, varIndex, runtime)
        else:
            if name != keywords['startTime']:
                ws_paper.write(IIDIndex, varIndex, paperData[field][1])
            ws_tablet.write(IIDIndex, varIndex, tabletData[field][1])
            row = str(IIDIndex + 1)
            col = xlrd.colname(varIndex)
            ws_diff.write(IIDIndex, varIndex,
                          xlwt.Formula('IF(Paper!' + col + row + '=Tablet!' + col + row +
                                       ';"";CONCATENATE(Paper!' + col + row +
                                       ';" --- ";Tablet!' + col + row + '))'))
        varIndex += 1
开发者ID:SwissTPH,项目名称:data-diff,代码行数:34,代码来源:createDiff.py


示例5: load_columns

def load_columns(file):
    rels = file.relationships.filter(type__name='Contains Column')
    table = load_file(file)

    matched = []
    for rel in rels:
        item = rel.right
        info = {
            'match': unicode(item),
            'rel_id': rel.pk,
        }
        if isinstance(item, UnknownItem):
            info['unknown'] = True

        if rel.range_set.filter(type='list').exists():
            col = rel.range_set.get(type='list').start_column
            info['name'] = table.field_map.keys()[col].replace('\n', ' - ')
            info['column'] = colname(col)
            info['colnum'] = col

        elif rel.range_set.filter(type='value').exists():
            info['name'] = get_range_value(table, rel.range_set.get(
                type='head'
            ))
            info['value'] = get_range_value(table, rel.range_set.get(
                type='value'
            ))
        matched.append(info)
    matched.sort(key=lambda info: info.get('colnum', -1))
    return matched
开发者ID:sheppard,项目名称:wq.db,代码行数:30,代码来源:tasks.py


示例6: get_keys_attrs

def get_keys_attrs(sheet):
    """keys and attrs
    keys come from row 1, a normal string is ok
    attrs live with these keys, note text
    """
    progress["row"] = 1
    keys = list(itertools.takewhile(lambda x: isinstance(x, str) and x,
                                    sheet.row_values(0)))
    assert keys, progress
    assert len(set(keys)) == len(keys), keys

    attrs = []
    cell_note_map = sheet.cell_note_map
    for colx in range(len(keys)):
        colname = xlrd.colname(colx)
        progress["column"] = colname
        note = cell_note_map.get((0, colx))
        if note:
            txt = note.text
            out = note_text_to_attr(txt)
            logging.debug(
                "note_text_to_attr_{}({!r}) = {}".format(colname, txt, out))
            attrs.append(out)
        else:
            attrs.append({})
    return keys, attrs
开发者ID:lwzm,项目名称:et,代码行数:26,代码来源:xls.py


示例7: show_row

 def show_row(bk, sh, rowx, colrange, printit):
     if bk.ragged_rows:
         colrange = range(sh.row_len(rowx))
     if not colrange: return
     for colx, ty, val, cxfx in get_row_data(bk, sh, rowx, colrange):
         if printit:
             print(json.dumps([ "cell", { "r": rowx, "c": colx, "cn": xlrd.colname(colx), "t": ty, "v": val }]))
开发者ID:pombredanne,项目名称:xlrd-parser,代码行数:7,代码来源:runxlrd-json.py


示例8: _retrieve_index_observations

    def _retrieve_index_observations(self, structure_obs_sheet):
        self._log.info("\t\tRetrieving index observations...")
        empty_row_error_cache = {}
        sheet_year = re.match(self._config.get("STRUCTURE_OBSERVATIONS", "SHEET_NAME_PATTERN"),
                              structure_obs_sheet.name).group("year")
        year_column = get_column_number(
            self._config_get("STRUCTURE_OBSERVATIONS", "OBSERVATION_YEAR_COLUMN", sheet_year))
        iso3_column = get_column_number(
            self._config_get("STRUCTURE_OBSERVATIONS", "OBSERVATION_ISO3_COLUMN", sheet_year))
        observation_name_row = self._config_getint("STRUCTURE_OBSERVATIONS", "OBSERVATION_NAME_ROW", sheet_year)
        observation_start_row = self._config_getint("STRUCTURE_OBSERVATIONS", "OBSERVATION_START_ROW", sheet_year)
        check_column = get_column_number(
            self._config_get("STRUCTURE_OBSERVATIONS", "OBSERVATION_CHECK_COLUMN", sheet_year))

        index_scaled_column = get_column_number(
            self._config_get("STRUCTURE_OBSERVATIONS", "OBSERVATION_INDEX_SCALED_COLUMN", sheet_year))
        index_rank_column = get_column_number(
            self._config_get("STRUCTURE_OBSERVATIONS", "OBSERVATION_INDEX_RANK_COLUMN", sheet_year))
        index_rank_change_column = get_column_number(
            self._config_get("STRUCTURE_OBSERVATIONS", "OBSERVATION_INDEX_RANK_CHANGE_COLUMN", sheet_year))

        try:
            column_name = structure_obs_sheet.cell(observation_name_row, index_scaled_column).value
            parsed_column = self._parse_index_scaled_column_name(column_name, sheet_year)
            # Sanity check useful if there could be more than one INDEX, otherwise this check could be relaxed
            if not parsed_column:
                raise IndicatorRepositoryError("Column name '%s' does not match INDEX pattern while parsing %s" % (
                    column_name, structure_obs_sheet.name))
            indicator = self._indicator_repo.find_indicator_by_code(parsed_column.group('index'))
            for row_number in range(observation_start_row, structure_obs_sheet.nrows):  # Per country
                if not structure_obs_sheet.cell(row_number, check_column).value or row_number in empty_row_error_cache:
                    if row_number not in empty_row_error_cache:
                        self._log.debug(
                            "Skipping row while parsing %s[%s] (did not detect value on check column, additional errors regarding this row will be omitted)" % (
                                structure_obs_sheet.name, row_number))
                    empty_row_error_cache[row_number] = True
                    continue
                try:
                    year = int(structure_obs_sheet.cell(row_number, year_column).value)
                    iso3 = structure_obs_sheet.cell(row_number, iso3_column).value
                    area = self._area_repo.find_by_iso3(iso3)
                    value = structure_obs_sheet.cell(row_number, index_scaled_column).value
                    rank = structure_obs_sheet.cell(row_number, index_rank_column).value
                    # Allow for empty values here
                    rank_change = na_to_none(structure_obs_sheet.cell(row_number,
                                                                      index_rank_change_column).value) if index_rank_change_column else None
                    excel_observation = ExcelObservation(iso3=iso3, indicator_code=indicator.indicator, year=year,
                                                         rank=rank, value=value, rank_change=rank_change)
                    self._excel_structure_observations.append((excel_observation, area, indicator))
                except AreaRepositoryError:
                    self._log.error("No area with code %s for indicator %s while parsing %s" % (
                        iso3, indicator.indicator, structure_obs_sheet.name))
                except:
                    self._log.error("Unexpected error parsing %s[%s]" % (structure_obs_sheet.name, row_number))
        except IndicatorRepositoryError:
            self._log.error("No INDEX indicator found while parsing %s [%s]" % (
                structure_obs_sheet.name, colname(index_scaled_column)))
        except ParserError as pe:
            self._log.error(pe)
开发者ID:TheWebFoundation,项目名称:odb-parser,代码行数:59,代码来源:observation_parser.py


示例9: get_excel_ref

def get_excel_ref(row, col):
    '''
    >>> get_excel_ref(0, 0)
    'A1'
    >>> get_excel_ref(3, 2)
    'C4'
    '''
    return xlrd.colname(col) + str(row + 1)
开发者ID:epogrebnyak,项目名称:make-xls-model,代码行数:8,代码来源:formula_parser.py


示例10: _parse_formula

 def _parse_formula(self, formula):
     """Формат формулы 2col/5col + 5 заменяем на
        B(current_row)/E(current_row) + 5
     """
     for column_text, col_number in re.findall(r'((\d+)col)', formula):
         letter = xlrd.colname(int(col_number))
         formula = formula.replace(column_text, '%s%s' % (letter, self.current_row_i+1))
     return formula
开发者ID:g10k,项目名称:awesome-pyexcel,代码行数:8,代码来源:core.py


示例11: _retrieve_dataset_assesments

    def _retrieve_dataset_assesments(self):
        self._log.info("\tRetrieving dataset assesments")
        dataset_obs_sheets = self._get_dataset_obs_sheets()
        indicator_code_error_cache = {}

        for dataset_obs_sheet in dataset_obs_sheets:  # Per year
            sheet_year = re.match(self._config.get("DATASET_OBSERVATIONS", "SHEET_NAME_PATTERN"),
                                  dataset_obs_sheet.name).group("year")
            year_column = get_column_number(
                self._config_get("DATASET_OBSERVATIONS", "OBSERVATION_YEAR_COLUMN", sheet_year))
            iso3_column = get_column_number(
                self._config_get("DATASET_OBSERVATIONS", "OBSERVATION_ISO3_COLUMN", sheet_year))
            indicator_column = get_column_number(
                self._config_get("DATASET_OBSERVATIONS", "OBSERVATION_INDICATOR_COLUMN", sheet_year))
            observation_name_row = self._config_getint("DATASET_OBSERVATIONS", "OBSERVATION_NAME_ROW", sheet_year)
            observation_start_row = self._config_getint("DATASET_OBSERVATIONS", "OBSERVATION_START_ROW", sheet_year)
            observation_start_column = get_column_number(
                self._config_get("DATASET_OBSERVATIONS", "OBSERVATION_START_COLUMN", sheet_year))

            for column_number in range(observation_start_column, dataset_obs_sheet.ncols):  # Per dataset indicator
                dataset_indicator_code = dataset_obs_sheet.cell(observation_name_row, column_number).value

                try:
                    dataset_indicator = self._indicator_repo.find_indicator_by_code(dataset_indicator_code)
                except IndicatorRepositoryError:
                    if dataset_indicator_code not in indicator_code_error_cache:
                        self._log.warn(
                            "No indicator with code %s found while parsing %s[%s] (additional errors regarding this indicator will be omitted)" % (
                                dataset_indicator_code, dataset_obs_sheet.name, colname(column_number)))
                        indicator_code_error_cache[dataset_indicator_code] = True
                    continue

                for row_number in range(observation_start_row, dataset_obs_sheet.nrows):  # Per country and variable
                    year = int(dataset_obs_sheet.cell(row_number, year_column).value)
                    iso3 = dataset_obs_sheet.cell(row_number, iso3_column).value
                    try:
                        indicator_code = dataset_obs_sheet.cell(row_number, indicator_column).value
                        indicator = self._indicator_repo.find_indicator_by_code(indicator_code)
                        area = self._area_repo.find_by_iso3(iso3)
                        value_retrieved = dataset_obs_sheet.cell(row_number, column_number).value
                        value = na_to_none(value_retrieved)
                        excel_dataset_observation = ExcelObservation(iso3=iso3, indicator_code=indicator_code,
                                                                     value=value,
                                                                     year=year,
                                                                     dataset_indicator_code=dataset_indicator_code)
                        self._excel_dataset_observations.append(
                            (excel_dataset_observation, area, indicator, dataset_indicator))
                    except IndicatorRepositoryError:
                        if indicator_code not in indicator_code_error_cache:
                            self._log.warn(
                                "No indicator with code %s found while parsing %s[%s] (additional errors regarding this indicator will be omitted)" % (
                                    indicator_code, dataset_obs_sheet.name, cellname(indicator_column, row_number)))
                            indicator_code_error_cache[indicator_code] = True
                    except AreaRepositoryError:
                        self._log.error("No area found with code %s while parsing %s" % (
                            iso3, dataset_obs_sheet.name))
开发者ID:TheWebFoundation,项目名称:odb-parser,代码行数:56,代码来源:observation_parser.py


示例12: get_excel_ref

def get_excel_ref(cell):
    """
    TODO: test below fails with strange message, need to fix

    >>> get_excel_ref((0,0))
    'A1'

    >>> get_excel_ref((1,3))
    'D2'
    """
    row = cell[0]
    col = cell[1]
    return xlrd.colname(col) + str(row + 1)
开发者ID:Imperat,项目名称:make-xls-model,代码行数:13,代码来源:eqcell_core.py


示例13: process_step_files

	def process_step_files(self, form):
		files = self.get_form_step_files(form)
		if self.steps.current == 'db_select':
			xlsfile = xlrd.open_workbook(file_contents = files['db_select-file'].read())
			table = xlsfile.sheets()[0]
			colname_list = []
			for colid in range(0,table.ncols-1):
				colname_list.append(xlrd.colname(colid))
			preview_list = []
			for rowid in range(0, 5):
				row = table.row_values(rowid)
				if row:
					preview_list.append(row)
			self.storage.extra_data['colname_list'] = colname_list
			self.storage.extra_data['preview_list'] = preview_list
		return files
开发者ID:forever043,项目名称:ictpat,代码行数:16,代码来源:Import.py


示例14: apply_attrs

def apply_attrs(values, attrs, custom_attrs, rowx):
    """convert and check cell.value
    if error occurs, set progress["error"] and break
    """
    fmt = "{} -> {} -> {}".format
    o = []
    colx = 0
    for x, attr in zip(values, attrs):
        custom_attr = custom_attrs.get((rowx, colx))
        if custom_attr:
            attr = attr.copy()
            attr.update(custom_attr)

        colname = xlrd.colname(colx)
        progress["column"] = colname
        abs_colname = fmt(progress["xls"], progress["sheet"], colname)

        if attr:
            #
            _type = attr.get("type")
            if _type:
                x = _type(x)
            #
            _test = attr.get("test")
            if _test:
                assert eval(_test, None, locals()), _test  # `S` and `o` can be used here
            #
            if attr.get("uniq"):
                uniq_tasks[abs_colname].append(x)
            #
            if attr.get("sort"):
                sort_tasks[abs_colname].append(x)
            #
            _ref = attr.get("ref")
            if _ref:
                abs_cellname = fmt(progress["xls"], progress["sheet"],
                                   xlrd.cellname(rowx, colx))
                ref_file_tasks[_ref].append([x, abs_cellname])

        o.append(x)
        colx += 1

    return o
开发者ID:lwzm,项目名称:et,代码行数:43,代码来源:xls.py


示例15: _write_sum

 def _write_sum(self):
     for col, field in enumerate(self.parent.headers):
         if field.need_sum or field.need_count or field.need_average or field.formula:
             letter = xlrd.colname(col)
             if field.formula:
                 formula = xlwt.Formula(self._parse_formula(field.formula))
             else:
                 if field.need_sum:
                     function_ = u'SUM(%s%s:%s%s)'
                 elif field.need_average:
                     function_ = u'ROUND(AVERAGE(%s%s:%s%s);0)'
                 else:
                     function_ = u'COUNTIF(%s%s:%s%s,"{condition}")'.format(condition=field.need_count)
                 formula = xlwt.Formula(
                     function_ % (
                         letter, self._data_start_row_i+1, letter, self.current_row_i
                     ))
             self.write(self.current_row_i, col, formula)
     self.current_row_i += 1
开发者ID:g10k,项目名称:awesome-pyexcel,代码行数:19,代码来源:core.py


示例16: xls_match

def xls_match(ptn, fname):
    """ 全シートのセルでptnにマッチするものをprint """
    try:
        book = xlrd.open_workbook(fname)
        for sheet in book.sheets():
            for row in range(sheet.nrows):
                for col in range(sheet.ncols):
                    val = sheet.cell_value(row, col)
                    # 文字列じゃないセルは文字列に変換
                    if (type(val) != str):
                        val = str(val)
                    if (re.match(ptn, val, flags=(re.MULTILINE | re.DOTALL))):
                        print("{0} in [{1}]{2}!{3}{4}".
                              format(
                                val,
                                fname,
                                sheet.name,
                                xlrd.colname(col),
                                row+1))
    except Exception as e:
        print(e)
开发者ID:tanuq,项目名称:scripts,代码行数:21,代码来源:xlsgrep.py


示例17: load_columns

def load_columns(run):
    table = run.load_io()
    cols = list(table.field_map.keys())
    matched = []
    for rng in run.range_set.exclude(type='data'):
        ident = rng.identifier
        info = {
            'match': str(ident),
            'mapping': ident.mapping_label,
            'rel_id': rng.pk,
            'type': ident.type,
        }

        if ident.type == 'meta':
            info['field_name'] = rng.identifier.field
        elif ident.type == 'attribute':
            info['field_name'] = rng.identifier.field
            info['attr_id'] = rng.identifier.attr_id
            info['attr_field'] = rng.identifier.attr_field
        else:
            info['value'] = ident.name

        if rng.type == 'list':
            col = rng.start_col
            info['name'] = cols[col].replace('\n', ' - ')
            info['column'] = colname(col)
            info['colnum'] = col

        elif rng.type == 'value':
            info['name'] = get_range_value(
                table, rng, rng.header_col, rng.start_col - 1
            )
            info['meta_value'] = get_range_value(
                table, rng, rng.start_col, rng.end_col
            )
            info['colnum'] = rng.start_col
            info['rownum'] = rng.start_row
        matched.append(info)
    matched.sort(key=lambda info: info.get('colnum', -1))
    return matched
开发者ID:wq,项目名称:django-data-wizard,代码行数:40,代码来源:tasks.py


示例18: conv

def conv(letters):
    alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    map = {
        "A" : "1",
        "B" : "2",
        "C" : "3",
        "D" : "4",
        "E" : "5",
        "F" : "6",
        "G" : "7",
        "H" : "8",
        "I" : "9",
        "J" : "A",
        "K" : "B",
        "L" : "C",
        "M" : "D",
        "N" : "E",
        "O" : "F",
        "P" : "G",
        "Q" : "H",
        "R" : "I",
        "S" : "J",
        "T" : "K",
        "U" : "L",
        "V" : "M",
        "W" : "N",
        "X" : "O",
        "Y" : "P",
        "Z" : "Q",
    }
    vals = ""
    for letter in letters:
        vals += map[letter.upper()]
    result = int(vals, 28) - 1
    result -= 2*(result / 27)
    if xlrd.colname(result) != letters.upper():
        print "Error cell reference out of range"
        return None
    return result
开发者ID:mountainpenguin,项目名称:convert,代码行数:39,代码来源:convert.py


示例19: load_columns

def load_columns(instance):
    rels = instance.relationships.filter(type__name='Contains Column')
    table = instance.load_io()
    cols = list(table.field_map.keys())

    matched = []
    for rel in rels:
        item = rel.right
        info = {
            'match': str(item),
            'rel_id': rel.pk,
        }
        if isinstance(item, UnknownItem):
            info['type'] = "unknown"
            info['value'] = item.name
        elif isinstance(item, Parameter):
            info['type'] = "parameter_value"
            info['parameter_id'] = get_object_id(item)
        elif isinstance(item, MetaColumn):
            info['type'] = item.type
            info['field_name'] = item.name

        if rel.range_set.filter(type='list').exists():
            col = rel.range_set.get(type='list').start_column
            info['name'] = cols[col].replace('\n', ' - ')
            info['column'] = colname(col)
            info['colnum'] = col

        elif rel.range_set.filter(type='value').exists():
            info['name'] = get_range_value(table, rel.range_set.get(
                type='head'
            ))
            info['value'] = get_range_value(table, rel.range_set.get(
                type='value'
            ))
        matched.append(info)
    matched.sort(key=lambda info: info.get('colnum', -1))
    return matched
开发者ID:TipOfit,项目名称:django-bulk-import-orchestrator,代码行数:38,代码来源:tasks.py


示例20: main

def main(args):
    citations.main(args)
    data = Data()

    pairs = {}
    languages = {}

    coords = {}
    for lang in dsv.rows(
        args.data_file('MB_Map_Data_Aug13WLabels'),
        namedtuples=True,
        newline='\n',
        encoding='latin1'
    ):
        coords[slug(lang.Label.split('<')[0].strip())] = (
            float(lang.y), float(lang.x))

    xls = xlrd.open_workbook(args.data_file('MB_BoCatSum_AFBO.xlsx'))
    matrix = xls.sheet_by_name('MB_BoCatSum_AFBO.txt')
    md = "area\trecipient language iso\trecipient language genus\tdonor language iso\tdonor language genus".split('\t')

    fields = []
    params = []
    for i in range(matrix.ncols):
        colname = xlrd.colname(i)
        if len(colname) == 2 and colname > 'BE':
            break
        colval = matrix.cell(0, i).value.strip()
        if (len(colname) == 1 and colname > 'G') or (len(colname) == 2 and colname < 'AY'):
            params.append(colval)
            fields.append(colval)
        else:
            fields.append(colval.lower())

    for f in fields:
        if fields.count(f) > 1:
            print(f)

    assert len(fields) == len(set(fields))

    for j in range(1, matrix.nrows):
        values = dict(zip(fields, [matrix.cell(j, i).value for i in range(matrix.ncols)]))
        try:
            id_ = int(values['perm.id'])
        except:
            continue

        pairs[id_] = values
        for type_ in ['recipient', 'donor']:
            languages[values[type_ + ' language'].strip()] = {
                'macroarea': values['area']}
            for md in ['iso', 'genus']:
                languages[values[type_ + ' language'].strip()][md] \
                    = values['%s language %s' % (type_, md)]

    for name in COORDS:
        assert name in languages

    sources = {}
    with open(args.data_file('MB_Case_List_with_links.html')) as fp:
        worddoc = fp.read()
        for m in re.finditer('\"__(?P<recid>[^_]+)__\"', worddoc):
            sources[m.group('recid').decode('utf8')] = 1
        soup = bs(worddoc)

    doc = {}
    cols = []
    table = soup.find('table')
    for tr in table.children:
        if tr.name != 'tr':
            continue
        tds = filter(lambda n: n.name == 'td', tr.children)
        if not cols:
            cols = map(text, tds)
        else:
            values = dict(zip(cols, tds))
        try:
            id_ = int(text(values['perm.id']))
            doc[id_] = values
            if id_ in pairs:
                assert doc['Recipient lg.'] == pairs[id_][1]['recipient language']
                assert doc['Don'] == pairs[id_][1]['donor language']
        except:
            continue

    dataset = common.Dataset(
        id='afbo',
        name="AfBo: A world-wide survey of affix borrowing",
        contact="[email protected]",
        domain="afbo.info",
        license='http://creativecommons.org/licenses/by/3.0/',
        jsondata={
            'license_icon': 'cc-by.png',
            'license_name': 'Creative Commons Attribution 3.0 Unported License'})

    DBSession.add(dataset)
    for i, spec in enumerate([('seifart', "Frank Seifart")]):
        DBSession.add(common.Editor(
            dataset=dataset,
            ord=i + 1,
#.........这里部分代码省略.........
开发者ID:clld,项目名称:waab,代码行数:101,代码来源:initializedb.py



注:本文中的xlrd.colname函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python xlrd.count_records函数代码示例发布时间:2022-05-26
下一篇:
Python xlrd.cellname函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap