#!/usr/bin/env python#
#-*- coding:utf-8 -*-
from phone import Phone
import datetime
input_csv = open('123.txt',encoding='utf-8')
output_csv = open('output4.txt','w')
i = 0
j = 0
for line in input_csv:
data = Phone().find(int(line[:-1]))
try:
phone = data['phone']
province = data['province']
city = data['city']
zip_code = data['zip_code']
area_code = data['area_code']
phone_type = data['phone_type']
staus = '1'
list_data = [phone,province,city,zip_code,area_code,phone_type,staus]
except:
j += 1
list_data = [line[:-1],'0','0','0','0','0','-1']
print('wrong data:[phone:%s,output:%s]' %(line[:-1],data))
if i % 100 == 0:
print('完成第%s次匹配:'%i,datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
output_str = ",".join(list_data)+'\n'
output_csv.write(output_str)
i += 1
print('已完成,共处理%s条号码,其中异常号码%s条' %(str(i),str(j)))