Ejemplo n.º 1
0
def download_vocabulary(n_clicks, sort_by, filter_query):
    vocabulary_view = vocabulary
    filtering_expressions = filter_query.split(' && ')
    for filter_part in filtering_expressions:
        col_name, op, filter_value = split_filter_part(filter_part)

        if op in ('eq', 'ne', 'lt', 'le', 'gt', 'ge'):
            vocabulary_view = [
                x for x in vocabulary_view
                if getattr(operator, op)(x[col_name], filter_value)
            ]
        elif op == 'contains':
            vocabulary_view = [
                x for x in vocabulary_view if filter_value in str(x[col_name])
            ]

    if len(sort_by):
        col = sort_by[0]['column_id']
        descending = sort_by[0]['direction'] == 'desc'
        vocabulary_view = sorted(vocabulary_view,
                                 key=lambda x: x[col],
                                 reverse=descending)

    with open('sde_vocab.csv', encoding='utf-8', mode='w', newline='') as fo:
        writer = csv.writer(fo)
        writer.writerow(vocabulary_view[0].keys())
        for item in vocabulary_view:
            writer.writerow([str(item[k]) for k in item])
    return dcc.send_file("sde_vocab.csv")
Ejemplo n.º 2
0
 def download_all_files(n_clicks, data):
     if n_clicks != None:
         path_to_local_zipfile = download_and_or_get_files(
             data,
             link_att_name,
             suggested_zipfilename,
             total_df=total_df)
         return dcc.send_file(path_to_local_zipfile)
def download_doc(n_clicks):
    return dcc.send_file(pwd+"\\..\\data\\report.pdf")
Ejemplo n.º 4
0
 def download(_):
     return dcc.send_file(os.path.join(asset_folder, filename))
Ejemplo n.º 5
0
def dash_send(name):
    temp, _ = temp_local_name(name)
    s3_bucket.download_file(name, temp)
    to_send = dcc.send_file(temp)
    os.remove(temp)
    return to_send
Ejemplo n.º 6
0
def download_local_file(pathname):
    return dcc.send_file(pathname)