拆分UIM卡号

import pandas as pd

if __name__ == '__main__':
    d = pd.read_excel('模板.xlsx')
    alist = d.values.tolist()
    blist=[]
    
    for i in range(len(alist)):
        blist.extend(list(range(alist[i][0],alist[i][1]+1)))
           
    d2 = pd.DataFrame({'UIM':blist}).astype('str')
    d3 = d2.reindex(index=list(range(0, d2.shape[0])))
    d3.to_excel('结果.xlsx')


import pandas as pd

d = pd.read_excel('模板.xlsx')
d1 = []
d2 = []
result=[]

for index,row in d.iterrows():
    if len(row[0]) != 19:
        temp = row[0][-2:]
        d2=(list(range(int(row[0][:-2]),int(row[1][:-2])+1) ))
        d3=[str(i) + temp for i in d2]
        result.extend(d3)    
    else:
        d1=list(range(int(row[0]),int(row[1])+1) )
        d4=[str(i) for i in d1]
        result.extend(d4)
        
dd = pd.DataFrame({'UIM':result})
dd = dd.reindex(index=list(range(0, dd.shape[0])))
dd.to_excel('结果.xlsx')

...

posted @ 2020-11-02 17:07  九命猫幺  阅读(321)  评论(0编辑  收藏  举报