Skip to content

Commit bbb9580

Browse files
committed
捯饬的一个简单的excel表格处理脚本
简单处理excel表格。将以域名开头单元格和邮件地址单元格分开。
1 parent 11bf542 commit bbb9580

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

HandleExcel.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#encoding=utf8
2+
3+
from __future__ import print_function
4+
import xlrd
5+
6+
data = xlrd.open_workbook('Latest.xlsx')
7+
#table = data.sheets()[0] #通过索引获取工作表
8+
#table = data.sheet_by_index(0) #通过索引顺序获取
9+
table = data.sheet_by_name(u'Sheet1') #通过名称获取
10+
#获取整行和整列的值
11+
#table.row_values(i)
12+
#table.col_values(i)
13+
14+
#获取行数和列数
15+
nrows = table.nrows
16+
ncols = table.ncols
17+
list_dispose = []
18+
for k, v in enumerate(table.col_values(0)):
19+
if v.startswith('@') or v.startswith(' @'):
20+
list_dispose.append(v)
21+
22+
count = 0
23+
#f = open("domain1.txt", 'wb')
24+
for exactone in list_dispose:
25+
#f.write(exactone)
26+
print(exactone,end = ' ')
27+
count+=1
28+
if (count%5) == 0:
29+
print(end = '\n')
30+
31+
#for i in list_dispose:
32+
# print(i, end=' ')
33+
# count += 1
34+
# if(count%5==0)
35+
# print(end='\n')
36+
# print("", file = f)
37+
38+
#可以在命令行中用如下命令来将打印结果导入到textfile.txt
39+
#python myawesomescript.py >> textfile.txt
40+
41+
print(ncols)
42+
print(nrows)

0 commit comments

Comments
 (0)