前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Python_Operation on Excel

Python_Operation on Excel

作者头像
AngelNH
发布2020-04-15 17:06:13
1580
发布2020-04-15 17:06:13
举报
文章被收录于专栏:AngelNI

====This my mood now====

I recently solve the problem of Excel ‘ data , it is hard to process Excel data because of huge amount of it.However, there is a better tool to process–Python.I simply write 34 lines to operation on Excel’s data to count th number of the key word.

Just for recording.

code

代码语言:javascript
复制
import xlrd
import xlwt
import re
import numpy as np
import pandas as pd

#import openpyxl


data = xlrd.open_workbook('C:\\Users\\hp\\Desktop\\数据信息3.xlsx')

table = data.sheets()[0]

ncols = table.col_values(12)
a = len(ncols)
pattern = re.compile(r'\d+')
d=[]
for i in range(1,a):
    #print(pattern.findall(ncols[i]))
   # print("\n")
    b = len(pattern.findall(ncols[i]))
    c=[]
    for j in range(0,b):
        if eval(pattern.findall(ncols[i])[j] )< 10 :
            c.append(pattern.findall(ncols[i])[j])
    #print(c)
    d.append(len(c))
    #print(d)
    f = xlwt.Workbook()               #创建工作簿
sheet1 = f.add_sheet(u'sheet1',cell_overwrite_ok=True) #创建sheet
for i in range(0,len(d)):
    sheet1.write(i+1,0,d[i])
f.save("C:\\Users\\hp\\Desktop\\2.xls")
print("结束")
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-06-20|,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • code
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档