-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyze_contacts.py
55 lines (39 loc) · 1.48 KB
/
analyze_contacts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
my_file = open("v.vcf", "r")
def finding_number_in_file(file):
number_list = []
for file_line in file.splitlines():
if str(file_line)[:9].__eq__("TEL;CELL:") or str(file_line)[:9].__eq__("TEL;HOME:"):
number_list.append(str(file_line)[9:])
return number_list
def is_number_nar(num):
return str(num)[:6].__eq__("+99470") \
or str(num)[:3].__eq__("070") \
or str(num)[:6].__eq__("+99477") \
or str(num)[:3].__eq__("077")
def is_number_azercell(num):
return str(num)[:6].__eq__("+99450") \
or str(num)[:3].__eq__("050") \
or str(num)[:6].__eq__("+99451") \
or str(num)[:3].__eq__("051")
def is_number_bakcell(num):
return str(num)[:6].__eq__("+99455") \
or str(num)[:3].__eq__("055")
def is_number_home(num):
return str(num)[:6].__eq__("+99412") \
or str(num)[:3].__eq__("012")
def analyze_numbers(list_numb):
az, bak, nar, hom = 0, 0, 0, 0
for number in list_numb:
if is_number_azercell(number):
az += 1
elif is_number_bakcell(number):
bak += 1
elif is_number_nar(number):
nar += 1
elif is_number_home(number):
hom += 1
return az, bak, nar, hom
va = str(my_file.read())
list_num = finding_number_in_file(va)
azercell, bakcell, nar_mobile, home = analyze_numbers(list_num)
print("Azercell: {0}, Bakcell: {1}, Nar: {2}, Home: {3}".format(azercell, bakcell, nar_mobile, home))