tornado下pandas ndarray乱试
2024-10-07 02:29:02
from tornado.web import RequestHandler
from pymongo import MongoClient
import pandas,xlrd
from pandas import DataFrame,Series
import json
import os
import time
currentpath =os.getcwd()
class multiupload(RequestHandler):
def get(self):
self.render('multifilesupload.html')
def post(self):
if self.request.files:
sourcefile = self.request.files
for i in sourcefile.keys():
targetpath = currentpath+"\\temfile\\"+sourcefile[i][]['filename']
with open(targetpath,"wb") as writer:
writer.write(sourcefile[i][]['body'])
self.write(json.dumps({"status":"ok"}))
else:
self.write(json.dumps({"status": "motherfuck"}))
class qingxiniaodao(RequestHandler):
def get(self):
self.render('mongowithpanda.html')
def post(self):
if self.request.files:
filename = self.request.files['fileobj'][]['filename']
filename =currentpath+"\\temfile\\"+filename
with open(filename,"wb") as writer:
writer.write(self.request.files['fileobj'][]['body'])
mydataframe = pandas.read_excel(filename)
#print(mydataframe)
title =[]
rets=[]
superdict = {}
retlist =[]
print("这是表头:",mydataframe.columns)
for i in mydataframe.columns:
title.append(i)
#mydataframe.values----结果集ndarray类型
print("算出数据集的行,列数:", mydataframe.values.shape)
rowcount = mydataframe.values.shape[]#ndarray的行数,--元组
i=
print("打印数据集的值:", mydataframe.values)
print("打印数据集的某行某列:", mydataframe.values[][])
k=
for i in range(,rowcount):
for k in range(,len(title)):
superdict[title[k]]=mydataframe.values[i][k]
retlist.append(superdict)
superdict = {}
i+=
# for i in title:
# superdict.a
self.write(json.dumps({"rets":retlist}))
输出结果:
这是表头: Index(['articleflid', 'articlefl', 'articleflcn'], dtype='object')
算出数据集的行,列数: (, )
打印数据集的值: [[ 'fist' '拳法']
[ 'kick' '腿法']
[ 'knee' '膝击']
[ 'wrestling' '摔法']
[ 'fit' '体能']]
打印数据集的某行某列: 拳法
最新文章
- 剖析AngularJS作用域
- C# DataTable 和List之间相互转换的方法
- 【leetcode】Rotate Image
- apache配置域名指向
- read the python code and predict the results --- from <;Learn Python The Hard Way>;
- 设计webapp的新思路
- Linux_ERROR 1045 (28000): Access denied for user &#39;root&#39;@&#39;localhost&#39;
- SpringBoot文档翻译系列——29.SQL数据源
- find the nth digit(二分查找)
- 智能合约语言 Solidity 教程系列2 - 地址类型介绍
- UE4笔记:利用Widget设计一个切换材质功能
- 2018.2.21 Python 初学习
- Docker容器镜像瘦身的三个小窍门(转)
- Heaps(Contest2080 - 湖南多校对抗赛(2015.05.10)(国防科大学校赛决赛-Semilive)+scu1616)
- (zhuan) Using convolutional neural nets to detect facial keypoints tutorial
- 06.linux文件目录操作命令
- python自学——文件修改
- zookeeper 官方文档——综述
- php格式化保留2位小数
- python版opencv:如何用笔记本摄像头拍照保存