databaker icon indicating copy to clipboard operation
databaker copied to clipboard

Think of cleverer way of doing split headers

Open frabcus opened this issue 11 years ago • 1 comments

e.g. In ashe, where it has one header cell split into three cells in Excel.

This is current code in recipe, which is horrid: https://github.com/scraperwiki/databaker/commit/6db4f5c379b1eb3e8eb5b18bf4b9cc43f21bb102

frabcus avatar Jan 27 '15 11:01 frabcus

This could be done by running this function to repeat the contents of multiple width cells into each cell

def FixMultipleCellsHeading(tab):
    hh = tab.excel_ref("C6:P9").is_not_whitespace()
    for cc in hh:
        val = cc.value
        ch = set(cc.children().unordered_cells)
        xwidth = len(set(c.x  for c in ch))
        ywidth = len(set(c.y  for c in ch))
        if ywidth == 1:
            for c in ch:
                c.value = val
        elif xwidth == 1:
            bottomcell = max(ch, key=lambda X:X.y)
            for c in ch:
                c.value = ''
            bottomcell.value = val

goatchurchprime avatar Aug 31 '17 13:08 goatchurchprime