def Get_Excel_Row_Values(filepath,sheetName,uniqueValue):
    
    Book = xlrd.open_workbook(filepath)
    Sheet = Book.sheet_by_name(sheetName)
    row_count = Sheet.nrows
    col_count = Sheet.ncols
    for i in range(0,row_count):
        for j in range(0,col_count):
            value = Sheet.cell_value(i, j)
            if value == uniqueValue:
                row_values = Sheet.row_values(i, 0)           
    return row_values
Beispiel #2
0
def read_xlsform_data(workbook: Book) -> OrderedDict:
    """Return XLSForm definition data read from an XLRD Workbook."""
    sheets = {x.name for x in workbook.sheets()}
    required = {"survey", "choices", "settings"}
    if not required.issubset(sheets):
        raise ValueError(
            "The required sheets for an XLSForm definition ({0}) were not "
            "found in the workbook sheets ({1}).".format(required, sheets))
    survey = xlrd_sheet_to_list_of_dict(
        workbook.sheet_by_name(sheet_name='survey'))
    choices = xlrd_sheet_to_list_of_dict(
            workbook.sheet_by_name(sheet_name='choices'))
    settings = xlrd_sheet_to_list_of_dict(
        workbook.sheet_by_name(sheet_name='settings'))
    form_def = OrderedDict()
    form_def['@settings'] = settings[0]
    for item in survey:
        if item['type'].startswith('select'):
            select_type, choice_name = item['type'].split(' ')
            choice_list = [x for x in choices
                           if x['list_name'] == choice_name]
            item['choices'] = choice_list
        form_def[item['name']] = item
    return form_def