Ejemplo n.º 1
0
 def __init__(self, sheet):
     self._sheet = sheet
     def get_data():
         for i in range(self._sheet.nrows):
             row = self._sheet.row(i)
             r = map(lambda x : x.value, row)
             yield r
     self._data = ftypes.list(*get_data())
Ejemplo n.º 2
0
def parse_file(fp, transforms):
    reader = csv.reader(fp)
    headers = reader.next()
    rows = [headers]
    for row in reader:
        values = [transforms[k](v) for (k, v) in zip(headers, row)]
        rows.append(values)
    return ftypes.list(*rows)
Ejemplo n.º 3
0
def extract_years(data, key, blank="-", years=years):
    newdata = ftypes.list()
    for year in years:
        added = False
        for item in data:
            if item['Year'] == str(year) and not added:
                added = True
                newdata.append(item[key])
        if not added:
            newdata.append(blank)
    return newdata
Ejemplo n.º 4
0
 def __init__(self, file_path, sheet_name):
     self.workbook = xlrd.open_workbook(file_path)
     self.sheet = self.workbook.sheet_by_name(sheet_name)
     self.data = ftypes.list(*self._load_data())
Ejemplo n.º 5
0
def pad(length, pad, oldlist):
    newlist = ftypes.list([pad] * length)
    for i in range(0, len(oldlist)):
        newlist[i] = oldlist[i]
    return newlist