def copy(wb): w = XLWTWriter() process( XLRDReader(wb,'unknown.xls'), w ) return w.output[0][1]
def post(self): fileinfo = self.request.files['image'][0] fname = fileinfo['filename'] extn = os.path.splitext(fname)[1] cname = str(uuid.uuid4()) + extn fh = open('images/' + cname, 'wb') fh.write(fileinfo['body']) process('images/' + cname, 'results/' + cname) self.render('result.html', name=cname)
def save(wb,filename_or_stream): if isinstance(filename_or_stream,basestring): filename = os.path.split(filename_or_stream)[1] stream = open(filename_or_stream,'wb') close = True else: filename = 'unknown.xls' stream = filename_or_stream close = False process( XLRDReader(wb,filename), StreamWriter(stream) ) if close: stream.close()
def predictml(): db.stream.drop() json = request.json df = pd.get_dummies(pd.DataFrame(json)) df = process(df) prediction = ml_model.predict(df).tolist() db.stream.insert_one({"data": json, 'state': prediction[0]}) return jsonify(1)