Пример #1
0
def downloadFile(id):
    file_obj = mongoengine.GridFSProxy(ObjectId(id))
    response = make_response(file_obj.read())
    response.headers['Content-Type'] = 'application/octet-stream'
    response.headers["Content-Disposition"] = "attachment; filename={}".format(
        file_obj.filename)
    return response
Пример #2
0
def filterTable():
    req = request.get_json()
    if (not req or ('file' not in req) or (len(req.get("file")) < 24)):
        #Bad Request
        return abort(400, 'Invalid Request')

    file = req.get('file')
    file_obj = mongoengine.GridFSProxy(ObjectId(file))
    df = pd.read_csv(file_obj)

    filtered = table_filter(df, req['ops'], req['column'], int(req['val']))
    headers, rows = decompose_df(filtered.where(pd.notnull(df), None))
    return make_response(jsonify({'headers': headers, 'rows': rows}), 200)
Пример #3
0
def getColumns():
    req = request.get_json()
    if (not req or ('file' not in req) or (len(req.get("file")) < 24)):
        #Bad Request
        return abort(400, 'Invalid Request')

    file = req.get("file")
    file_obj = mongoengine.GridFSProxy(ObjectId(file))

    if (not file_obj or file_obj.length == 0):
        #Bad Request
        return abort(400, 'Invalid file')

    df = pd.read_csv(file_obj)
    return jsonify(df.columns.tolist())
Пример #4
0
def getTable():

    req = request.get_json()
    if (not req or ('file' not in req) or (len(req.get("file")) < 24)):
        #Bad Request
        return abort(400, 'Invalid Request')

    file = req.get('file')
    file_obj = mongoengine.GridFSProxy(ObjectId(file))
    df = pd.read_csv(file_obj)
    df = df.where(pd.notnull(df), None)

    headers, rows = decompose_df(df)
    # print(headers)
    # return jsonify(headers)

    return jsonify({'headers': headers, 'rows': rows})
Пример #5
0
def getScatterGraphData():
    req = request.get_json()

    if (not req or ('file' not in req) or ('columnX' not in req)
            or ('columnY' not in req) or (len(req.get("file")) < 24)):
        #Bad Request
        return abort(400, 'Invalid Request')

    file = req.get('file')
    file_obj = mongoengine.GridFSProxy(ObjectId(file))

    if (not file_obj or file_obj.length == 0):
        #Bad Request
        return abort(400, 'Invalid file')

    df = pd.read_csv(file_obj)
    # print(linear_extrapolation_data_output(df, req.get('columnX'), req.get('columnY')))
    return jsonify(
        linear_extrapolation_data_output(df, req.get('columnX'),
                                         req.get('columnY')))
Пример #6
0
def getLineGraphData():
    req = request.get_json()

    if (not req or ('file' not in req) or ('columnX' not in req)
            or ('columnY' not in req) or (len(req.get("file")) < 24)):
        #Bad Request
        return abort(400, 'Invalid Request')

    file = req.get('file')
    file_obj = mongoengine.GridFSProxy(ObjectId(file))

    if (not file_obj or file_obj.length == 0):
        #Bad Request
        return abort(400, 'Invalid file')

    df = pd.read_csv(file_obj)
    # print(linear_extrapolation_data_output(df, req.get('columnX'), req.get('columnY')))
    columnX = req.get('columnX')
    columnY = req.get('columnY')
    prediction = time_series_linear_regression_data_outputs(
        df, columnX, columnY)
    actual = time_series_data_outputs(df, columnX, columnY)

    return jsonify(actual + prediction)
Пример #7
0
def getDataFromColumn():

    req = request.get_json()
    if (not req or ('file' not in req) or ('columnName' not in req)
            or (len(req.get("file")) < 24)):
        #Bad Request
        return abort(400, 'Invalid Request')

    file = req.get('file')
    column_name = req.get('columnName')
    file_obj = mongoengine.GridFSProxy(ObjectId(file))

    if (not file_obj or file_obj.length == 0):
        #Bad Request
        return abort(400, 'Invalid file')

    df = pd.read_csv(file_obj)
    column = df.get(column_name)

    if (column is None or column.empty):
        #Bad Request
        return abort(400, 'Invalid Column')

    return jsonify(column.tolist())
Пример #8
0
def getFileId(id):
    files = mongoengine.GridFSProxy(id)
    return files