kifield/kifield.py
def find_header(ws):
    """Find the spreadsheet row that most likely contains the field headers."""

    # Look for the first occurrence of the row with the most entries.
    # That's probably the header row.
    max_width = 0
    header_row_num = 0
    header = []
    r = enumerate(ws.rows, 1)
    for row_num, row in r:
        width = len(row) - [c.value for c in row].count(None)
        if width > max_width:
            max_width = width
            header_row_num = row_num
            header = [cell for cell in row]

    logger.log(
        DEBUG_DETAILED,
        "Header on row {}: {}.".format(header_row_num, [c.value for c in header]),
    )
    return header_row_num, header
Find the spreadsheet row that most likely contains the field headers.
Find the spreadsheet row that most likely contains the field headers.
Find the spreadsheet row that most likely contains the field headers .
def find_header(ws):
    max_width = 0
    header_row_num = 0
    header = []
    r = enumerate(ws.rows, 1)
    for row_num, row in r:
        width = len(row) - [c.value for c in row].count(None)
        if width > max_width:
            max_width = width
            header_row_num = row_num
            header = [cell for cell in row]
    logger.log(
        DEBUG_DETAILED,
        "Header on row {}: {}.".format(header_row_num, [c.value for c in header]),
    )
    return header_row_num, header
def find_header ( ws ) : max_width = 0 header_row_num = 0 header = [ ] r = enumerate ( ws . rows , 1 ) for row_num , row in r : width = len ( row ) - [ c . value for c in row ] . count ( None ) if width > max_width : max_width = width header_row_num = row_num header = [ cell for cell in row ] logger . log ( DEBUG_DETAILED , "Header on row {}: {}." . format ( header_row_num , [ c . value for c in header ] ) , ) return header_row_num , header
Find the spreadsheet row that most likely contains the field headers.
Find the spreadsheet row that most likely contains the field headers .
"""Find the spreadsheet row that most likely contains the field headers.""" # Look for the first occurrence of the row with the most entries. # That's probably the header row.
ws