def get_xl_data2(): from officelib.xllib.xlcom import xlBook2 from officelib.const import xlDown from pysrc.snippets import smooth1 import re from itertools import takewhile xl, wb = xlBook2('PID.xlsx') ws = wb.Worksheets('p30') cells = ws.Cells # columns = (5, 9, 13, 17, 21, 25, 29) columns = range(2, 19, 4) parse_name = re.compile(r"p(\d*)i([\d\.]*)").match all_dat = [] ap = all_dat.append row = 2 def good(o): return o != (None, None) for col in columns: data = cells.Range(cells(row, col), cells(row, col + 1).End(xlDown)).Value name = cells(1, col + 1).Value xldata = takewhile(good, data) x, y = zip(*xldata) x_data, y_data = smooth1(x, y) p, i = parse_name(name).groups() ap(xlData(name, x_data, y_data, p, i)) return all_dat
def get_xl_data(): from officelib.xllib.xlcom import xlBook2 from officelib.const import xlDown from itertools import dropwhile import re xl, wb = xlBook2('PID.xlsx') ws = wb.Worksheets(3) cells = ws.Cells columns = (5, 9, 13, 17, 21, 25, 29) def bad(tpl): x, y = tpl return x is None or y < 28 parse_name = re.compile(r"p(\d*)i([\d\.]*)").match all_dat = [] ap = all_dat.append row = 2 for col in columns: xldat = cells.Range(cells(row, col), cells(row, col + 1).End(xlDown)).Value name = cells(1, col + 1).Value data = dropwhile(bad, xldat) x, y = tuple(zip(*data)) x_data, y_data = smooth1(x, y) p, i = parse_name(name).groups() ap(xlData(name, x_data, y_data, p, i)) return all_dat