final
This commit is contained in:
@@ -3,7 +3,7 @@ from datetime import datetime
|
||||
import sys
|
||||
import pandas as pd
|
||||
|
||||
FILE = 'TMGDSP202105.CSV'
|
||||
FILE = 'TMGDSP202110.CSV'
|
||||
|
||||
#usrmonth = input("Month to be processed: ")
|
||||
|
||||
@@ -70,10 +70,12 @@ with open(FILE, newline='', encoding='utf-8') as csvfile:
|
||||
|
||||
MSISDN = int(row['MSISDN'])
|
||||
ICCID = int(row['ICCID'])
|
||||
price1 = float(row['CHARGE_NET'].replace(',','.'))
|
||||
|
||||
price = round(price1, 5)
|
||||
print("before conditions price: ",price)
|
||||
|
||||
print("charge_net: ",row['CHARGE_NET'])
|
||||
price = float(row['CHARGE_NET'].replace(',','.'))
|
||||
price = round(price, 5)
|
||||
|
||||
print("before conditions price: ",price, "for: ",ICCID)
|
||||
|
||||
typ = None
|
||||
if row['CHARGE_TYPE'] == "Pravidelné měsíční poplatky":
|
||||
@@ -102,12 +104,12 @@ with open(FILE, newline='', encoding='utf-8') as csvfile:
|
||||
dictionary[MSISDN] = {'ICCID':ICCID,'data':0.00000, 'sms':0.00000, 'other':0.00000, 'smscount':pricesms}
|
||||
print("Creating new dictionary: ", dictionary[MSISDN])
|
||||
|
||||
else:
|
||||
print("Adding: ", price, " for: ", dictionary[MSISDN], "TYP: ",typ)
|
||||
add_dict(MSISDN, typ, price)
|
||||
if row['INCREMENT'] == "SMS":
|
||||
print("pricesms: ",pricesms," for unit: ",dictionary[MSISDN])
|
||||
add_dictsms(MSISDN, pricesms)
|
||||
|
||||
print("Adding: ", price, " for: ", dictionary[MSISDN], "TYP: ",typ)
|
||||
add_dict(MSISDN, typ, price)
|
||||
if row['INCREMENT'] == "SMS":
|
||||
print("pricesms: ",pricesms," for unit: ",dictionary[MSISDN])
|
||||
add_dictsms(MSISDN, pricesms)
|
||||
|
||||
|
||||
|
||||
@@ -141,7 +143,7 @@ print("Count of units: ", len(dictionary.keys()))
|
||||
|
||||
csv_columns = ['takhleuztoneudelam', 'ICCID', 'data', 'sms', 'other', 'smscount']
|
||||
try:
|
||||
with open('fakturace_tmgdsp_export_20211110v3.csv', 'w') as csvfile:
|
||||
with open('fakturace_tmgdsp_export_202110v1.csv', 'w') as csvfile:
|
||||
w = csv.DictWriter(sys.stdout, csv_columns)
|
||||
for key, val in sorted(dictionary.items()):
|
||||
row = {'takhleuztoneudelam': key}
|
||||
@@ -151,4 +153,4 @@ try:
|
||||
writer.writerow(row)
|
||||
|
||||
except IOError:
|
||||
print(f"I/O error: {IOError}")
|
||||
print(f"I/O error: {IOError}")
|
||||
87
vdgdsp.py
87
vdgdsp.py
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user