seasondaily

描述:将Excel表中的数据按照每50个进行分组,并输出保存到不同的文件。

 1 #coding=utf-8
 2 import xlrd
 3 
 4 def read(file):
 5     data = xlrd.open_workbook(file)
 6     table = data.sheets()[0]
 7     nrows = table.nrows
 8     ncols = table.ncols
 9     
10 
11     n = 0
12     
13     filename = 1
14     fopen = open(\'d:/zemail/\'+str(filename)+\'.txt\', \'w\')
15 
16     for i in xrange(0, nrows):
17         rowValues = table.row_values(i)
18         n = n+1
19         if n%51 != 0:
20             for item in rowValues:
21                 #print item
22                 fopen.write(item+\'\n\')
23         else:
24             fopen.close()
25             filename = n
26             fopen = open(\'d:/zemail/\'+str(filename)+\'.txt\', \'w\')
27     fopen.close()
28         
29 
30 #def create(filename):
31     #if os.path.exists(fname):
32         #print "File already exists!"
33     #fopen = open(filename, \'w\')
34     #fopen.close()
35 
36 if __name__ == \'__main__\':
37     path = "d:/email.xlsx"
38     read(path)

 

分类:

技术点:

相关文章:

  • 2021-12-31
  • 2021-10-04
  • 2021-06-01
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2021-07-11
  • 2022-12-23
猜你喜欢
  • 2021-11-26
  • 2021-06-11
  • 2022-02-03
  • 2021-04-13
  • 2021-09-15
  • 2021-12-12
相关资源
相似解决方案