Ejemplo n.º 1
0
def process_csv(request):
    """ Return JSON with uploaded CSV fields """
    data = yield from request.post()

    file_name = data.get('file_name')
    file_text = data.get('file_text')

    persisted_id = filiaweb.persist_csv_data(file_name, file_text)
    process_result = filiaweb.process_csv_data(persisted_id, file_text)

    return {'json': process_result}
Ejemplo n.º 2
0
def process_csv_from_file(filepath):
    if os.path.exists(filepath):
        file_name = os.path.basename(filepath)
        file_text = open(filepath, 'rb').read()

        persisted_id = filiaweb.persist_csv_data(file_name, file_text.decode('utf-8'))
        process_result = filiaweb.process_csv_data(persisted_id, file_text.decode('utf-8'))

        print(process_result)
    else:
        print("File not found")