Ejemplo n.º 1
0
 def print_all(self, sql, title=None):
     try:
         if isinstance(sql, str):
             sql = execute(sql, self)
         if isinstance(title, str):
             print(title)
         print(etl.lookall(sql))
     except SQLError as e:
         print(e)
Ejemplo n.º 2
0
def geojson_fc_to_csv(fc):
    rows = []
    for f in fc['features']:
        feature = {}
        feature.update(f['properties'])
        geom = f['geometry']['coordinate']
        feature.update({'lon': geom[0], 'lat': geom[1]})
        rows.append(feature)
    table = etl.fromdicts(rows)
    return etl.lookall(table)
Ejemplo n.º 3
0
def getit():
    for n, s in enumerate(shifts()):
        shift = collections.OrderedDict()
        shift['First Name'] = s['user']['firstname']
        shift['Last Name'] = s['user']['lastname']
        shift['Role'] = s['role']['name'] if s['role'][
            'name'] else "Please assign role"
        shift['Date'] = s['shift']['start'].split(" ")[0]
        shift['Start'] = s['shift']['start'].split(" ")[1].split(":")[0]
        shift['End'] = s['shift']['end'].split(" ")[1]

        pprint(shift)
        report.append(shift)

    t = etl.fromdicts(report)
    print(etl.lookall(t))
Ejemplo n.º 4
0
def projects(ctx: typer.Context):
    data = fromdicts(get_toggl_user()['projects'])
    data = petl.selecteq(data, 'wid',
                         ctx.meta['config']['toggl']['workspace_id'])
    print(petl.lookall(data))
Ejemplo n.º 5
0
table1 = etl.addfield(
    etl.convertnumbers(
        etl.setheader(etl.fromcsv('winequality-red.csv'), table_header)),
    "Type", "Red")
table2 = etl.addfield(
    etl.convertnumbers(
        etl.setheader(etl.fromcsv('winequality-white.csv'), table_header)),
    "Type", "White")

#print(etl.head(table1))
#print(etl.head(table2))

table1_filtered = etl.select(table1, "Quality", lambda v: v > 6)
table2_filtered = etl.select(table2, "Quality", lambda v: v > 4)

good_wines = etl.cat(table1_filtered, table2_filtered)

good_wines_enhanced = etl.addfields(
    good_wines,
    [("Max Acidity",
      lambda rec: rec["Fixed Acidity"] + rec["Volatile Acidity"]),
     ("Locked SO2", lambda rec: rec["Total SO2"] - rec["Free SO2"])])
#print(etl.head(good_wines_enhanced))
#print(etl.tail(good_wines_enhanced))

gwe_sorted = etl.sort(good_wines_enhanced, key=["Quality", "Sugar"])

#print(etl.head(gwe_sorted))
print(etl.lookall(etl.tail(gwe_sorted, 500)))
Ejemplo n.º 6
0
for d in departments:
    print(d)
    table2 = etl.select(table, 'Department', lambda v: v == d ).facet("Day" )
    report = (
          etl
         .empty()
         .addcolumn('12-13', list(table2["2017-12-13"].values("Shift")))
         .addcolumn('12-14', list(table2["2017-12-14"].values("Shift")))
         .addcolumn('12-15', list(table2["2017-12-15"].values("Shift")))
         .addcolumn('12-16', list(table2["2017-12-16"].values("Shift")))
         .addcolumn('12-17', list(table2["2017-12-17"].values("Shift")))

         )


    pprint(etl.lookall(report,style='minimal'))
# sys.exit()

#
# table15 = table['2017-12-15']
# print(etl.look(table15))
# table16 = table['2017-12-16']
# table17 = table['2017-12-17']
# full = etl.annex(table15, table16,table17)
# print(etl.lookall(full))
 # etl.addcolumn(table1, 'baz', col)
 #table2 = etl.addfield(table1, 'baz', 42)
#etl.addfieldusingcontext(table1, 'baz', upstream)
#etl.addfieldusingcontext(table2, 'quux', downstream)

 #