Skynet

---------- ---------- 我的新 blog : liukaiyi.cublog.cn ---------- ----------

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  112 Posts :: 1 Stories :: 49 Comments :: 0 Trackbacks
参考:
显示   【sheet数】【sheet Name】【(第一行,第一列)】  
print sheets[0][1][(0,0)]


from pyExcelerator import *
sheets = parse_xls('src/天娱版权明确的歌曲清单.xls')
sdata=sheets[0][1]

#按行数 迭代
for tnum in range(max([tmp[0] for tmp in sdata])):
 print sdata[(tnum,0)],'-',sdata[(tnum,1)]

 





from pyExcelerator import *
import os
sheets 
= parse_xls('xls/版权确认清单表20090601.3.xls')
cpcc
= parse_xls('xls/CP对应表.xls')

g2u
=lambda str : str.decode('gbk')
bmug
=lambda str : unicode(str).encode("gbk")
def cfsize(cha):
    
if len(cha)==1
        
return ord(cha)-ord('A'
    
else : 
        fsize
=0
        fnum
=cfsize('Z')+1
        cc
=list(cha)
        
for tnum in range(len(cc)):
            fsize
+=fnum*tnum+cfsize(cc[tnum])
        
return fsize



cpccmap
={}
tsdata
=cpcc[0][1]
for tnum in range(max([tmp[0] for tmp in tsdata]))[:]:
    cpname
=tsdata[(tnum,cfsize('A'))]
    cpid
=("%s" % (tsdata[(tnum,cfsize('B'))])).split(".")[0]
    cpccmap[cpname]
=cpid


def insertData(cpid,cpname, music,actor,copyrightname,ytime,txls,rows):
    
#print music,actor,cpname,ytime,txls,rows
    txls.write(rows,cfsize('A'),music)
    txls.write(rows,cfsize(
'B'),actor)
    txls.write(rows,cfsize(
'C'),cpname)
    txls.write(rows,cfsize(
'D'),u'中国大陆')
    txls.write(rows,cfsize(
'E'),u'')
    txls.write(rows,cfsize(
'F'),u'')
    txls.write(rows,cfsize(
'G'),u'')
    txls.write(rows,cfsize(
'H'),u'')
    txls.write(rows,cfsize(
'I'),ytime.split(' ')[0])
    txls.write(rows,cfsize(
'J'),u'')
    txls.write(rows,cfsize(
'K'),'0')
    txls.write(rows,cfsize(
'L'),u'许可')
    txls.write(rows,cfsize(
'M'),'200')
    txls.write(rows,cfsize(
'N'),u'许可')
    txls.write(rows,cfsize(
'O'),'0')
    txls.write(rows,cfsize(
'P'),u'许可')
    txls.write(rows,cfsize(
'Q'),'0')
    txls.write(rows,cfsize(
'U'),copyrightname)
    
    txls.write(rows,cfsize(
'V'),'100%')
    txls.write(rows,cfsize(
'W'),cpname)
    txls.write(rows,cfsize(
'X'),'100%')


cpmap
={}
for tsdata in sheets :
    
try:
        sdata
=tsdata[1]
        
#按行数 迭代 
        for tnum in range(max([tmp[0] for tmp in sdata]))[1:]:
            cpid
=sdata[(tnum,cfsize('C'))]
            cpname
=sdata[(tnum,cfsize('D'))] #.upper()
            music=sdata[(tnum,cfsize('E'))]
            actor
=sdata[(tnum,cfsize('F'))]
            copyrightname
=sdata[(tnum,cfsize('H'))]
            ytime
=sdata[(tnum,cfsize('K'))]
            
if not cpmap.has_key(cpname) :
                tmpf
=bmug("cp -r 0000_20090602/ data3/"+cpid+"_20090602/ " )
                os.system(tmpf)
                txls
=Workbook()
                tsheet
=txls.add_sheet(u'版权列表')
                cpmap[cpname]
=[txls,1,'data3/'+cpid+u'_20090602/产品信息/'+cpid+'_20090602_01_copyright.xls',tsheet]
                titles
='歌曲名称    演唱者    提供者    授权区域    电子化版权信息(有/无)    需要DRM处理(是/否)    支持二次开发(是/否)    相关版权合同记录(有/无)    授权期限    全曲授权    全曲价格    彩铃授权    彩铃价格    IVR授权    IVR价格    振铃授权    振铃价格    ISRC    UPC    ICPN    词曲著作权权利人一    词曲比例一    录音权权利人一    录音比例一    词曲著作权权利人二    词曲比例二    录音权权利人二    录音比例二    词曲著作权权利人三    词曲比例三    录音权权利人三    录音比例三    其它'.split('\t')
                
for ttnum in range(len(titles)):
                    tsheet.write(0,ttnum,g2u(titles[ttnum]))
                insertData(cpid,cpname, music,actor,copyrightname,ytime,tsheet,
1)
            
else :
                tsheet
=cpmap[cpname][3]
                cpmap[cpname][
1]=cpmap[cpname][1]+1
                insertData(cpid,cpname, music,actor,copyrightname,ytime,tsheet,cpmap[cpname][
1])
    
except :
        
print "[error]: ", music,actor,cpname,ytime,txls
        
pass


for tkey in cpmap.keys() :
    ct
=cpmap[tkey]
    
print ct[2]
    ct[0].save(ct[
2])





 



整理 www.blogjava.net/Good-Game
posted on 2009-05-29 22:23 刘凯毅 阅读(542) 评论(0)  编辑  收藏 所属分类: python

只有注册用户登录后才能发表评论。


网站导航: