把excel中的手機號變成vcf
阿新 • • 發佈:2020-09-16
import xlrd
import re
def qu():
wb = xlrd.open_workbook('xxxxxxxx.xlsx')
sh = wb.sheet_by_name('9.10')
for i in range(sh.nrows)[1:200]:
i_li = sh.row_values(i)
print(i_li)
if i_li[-1]:
number_list = re.findall('\d+',str(i_li[-1]))
print(number_list)
for number in number_list:if number !='0':
with open("通訊.vcf", "a", encoding='utf-8')as f:
f.write('BEGIN:VCARD')
f.write('\n')
f.write('VERSION:3.0')
# f.write('\n')
#
# f.write('N;CHARSET=utf-8:;{};;;'.format(i_li[0]))
f.write('\n')
# f.write('FN;CHARSET=utf-8: {}'.format(i_li[0]))
f.write('FN:{}'.format(i_li[0]))
f.write('\n')
f.write('TEL;type=CELL;type=VOICE;type=pref:{}'.format(int(float(number))))# f.write('TEL;CELL:{}'.format(int(float(bunber))))
f.write('\n')
f.write('END:VCARD')
f.write('\n')
qu()