This commit is contained in:
2022-02-14 18:38:00 +01:00
parent 4bfe868a6c
commit 2e72350a36
2 changed files with 70 additions and 45 deletions

View File

@@ -35,16 +35,14 @@ def add_dict2(ICCID, IMSI):
dict['IMSI'] = IMSI
print('updated', dict)
def add_dictsms(id, key, value):
def add_dictsms(id, pricesms):
dict = dictionary.get(id)
value_ = float(value)
if key in dict:
dict[key] == value_
else:
print("Never should happen", id)
print("increasing sms dict key for dict: ",dict," for :",pricesms)
dict["smscount"] += pricesms
def add_dictsmsprice(ICCID3, pricesms):
dict2 = dictionary.get(ICCID3)
dict2 = dictionary.get(ICCID2)
print("section 3, add to sms")
print(dict2)
print("increasing sms dict key for dict: ",dict2 , " for :", pricesms)
@@ -96,7 +94,7 @@ with open(FILE, newline='', encoding="utf-8") as csvfile:
print("Creating dictionary: ", ICCID)
dictionary[ICCID] = {'IMSI': 0,'data': price, 'sms': 0.00000, 'other': 0.00000, 'smscount': 0}
xxx = []
print("Start section 2")
with open(FILE2, newline='', encoding="utf-8") as csvfile2:
reader2 = csv.DictReader(csvfile2, delimiter=',')
@@ -105,36 +103,61 @@ with open(FILE2, newline='', encoding="utf-8") as csvfile2:
IMSI = int(row['IMSI'])
ICCID2 = ICCID3 = int(row['ICCID'])
ICCID3 = int(ICCID2)
print("Je to jeste ok? ",ICCID3)
xxx.append(int(row['ICCID']))
if ICCID2 in dictionary:
print("Adding IMSI: ",IMSI ,"to dictionary: ", ICCID2)
add_dict2(ICCID2, IMSI)
print("sec2 end")
print("Start section 3")
i = 0
x = 0
with open(FILE3, newline='', encoding="utf-8") as csvfile3:
reader3 = csv.DictReader(csvfile3, delimiter=',')
for row in reader3:
smspay = int(row['Nr. of SMS payload'])
smsmo = int(row['Nr. of SMS MO'])
imsi = int(row['IMSI'])
print("IMSI: ",imsi)
print("smspay: ",smspay)
print("smsmo: ", smsmo)
price = smspay * smsmo * 1.28
for key,value in dictionary.items():
print(key, value)
print("iterations: ", x)
print("succesfuly paired: ", i)
x += 1
if type(value) is dict:
for key, val in value.items():
# print("Start section 3")
# with open(FILE3, newline='', encoding="utf-8") as csvfile3:
# reader3 = csv.DictReader(csvfile3, delimiter=',')
# for row in reader3:
# print(xxx[1])
# print("we got bad ICCIDfinal from section 2! :",xxx[5])
# IMSI2 = int(row['IMSI'])
# print(row['Nr. of SMS payload'])
# print(row['Nr. of SMS MO'])
# smspay = int(row['Nr. of SMS payload'])
# smsmo = int(row['Nr. of SMS MO'])
#
#
# price = smspay * smsmo * 1.28
#
#
# print("Dict: ", dict)
# for x in xxx:
#
# print("Adding SMSprice: ",price ,"to dictionary: ", x)
#
# add_dictsmsprice(x, price)
#print(key,"→", val)
if val == imsi:
print("succesfuly paired: ", i)
i += 1
print("got it, IMSI: ", imsi," is paired to ICCID:", ICCID2)
#add_dictsms(ICCID2, pricesms)
print(dictionary[ICCID2])
#sys.exit()
# just get the dictionary key by matching IMSI
#dictionary = {'george': 16, 'amber': 19}
#sys.exit()
#print("Adding SMSprice: ",price ,"to dictionary: ", x)
#add_dictsmsprice(x, price)