final version
This commit is contained in:
@@ -41,6 +41,12 @@ def add_dictsms(id, pricesms):
|
|||||||
print("increasing sms dict key for dict: ",dict," for :",pricesms)
|
print("increasing sms dict key for dict: ",dict," for :",pricesms)
|
||||||
dict["smscount"] += pricesms
|
dict["smscount"] += pricesms
|
||||||
|
|
||||||
|
def add_dictdataamount(id, dataamount):
|
||||||
|
dict = dictionary.get(id)
|
||||||
|
|
||||||
|
print("increasing dataamount dict key for dict: ",dict," for :",dataamount)
|
||||||
|
dict["dataamount"] += dataamount
|
||||||
|
|
||||||
#MAIN
|
#MAIN
|
||||||
|
|
||||||
print("Start")
|
print("Start")
|
||||||
@@ -111,8 +117,6 @@ with open(FILE, newline='', encoding="utf-8") as csvfile:
|
|||||||
else:
|
else:
|
||||||
typ = 'other'
|
typ = 'other'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if row['Jednotka'] == "ks":
|
if row['Jednotka'] == "ks":
|
||||||
|
|
||||||
pricesms = int(row['Počet jednotek – volné']) + int(row['Počet jednotek – účtované'])
|
pricesms = int(row['Počet jednotek – volné']) + int(row['Počet jednotek – účtované'])
|
||||||
@@ -121,11 +125,21 @@ with open(FILE, newline='', encoding="utf-8") as csvfile:
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
pricesms = 0
|
pricesms = 0
|
||||||
|
|
||||||
|
if row['Jednotka'] == "kB":
|
||||||
|
|
||||||
|
dataamount = (int(row['Počet jednotek – volné']) + int(row['Počet jednotek – účtované'])) / 1024
|
||||||
|
print("rowjednotka: ",row['Jednotka'])
|
||||||
|
print("sms price: ",pricesms,MSISDN)
|
||||||
|
|
||||||
|
else:
|
||||||
|
dataamount = 0
|
||||||
|
|
||||||
|
|
||||||
#only if not exist create new record in dictionary for ID
|
#only if not exist create new record in dictionary for ID
|
||||||
if not MSISDN in dictionary:
|
if not MSISDN in dictionary:
|
||||||
print("Creating dictionary: ", MSISDN)
|
print("Creating dictionary: ", MSISDN)
|
||||||
dictionary[MSISDN] = {'data':0.00000, 'sms':0.00000, 'other':0.00000, 'smscount':pricesms}
|
dictionary[MSISDN] = {'data':0.00000, 'sms':0.00000, 'other':0.00000, 'smscount':pricesms, 'dataamount':dataamount}
|
||||||
|
|
||||||
if price != '':
|
if price != '':
|
||||||
print("Editing dictionary: ", MSISDN, "typ: ", typ, "cena: ", price)
|
print("Editing dictionary: ", MSISDN, "typ: ", typ, "cena: ", price)
|
||||||
@@ -133,9 +147,11 @@ with open(FILE, newline='', encoding="utf-8") as csvfile:
|
|||||||
|
|
||||||
add_dict(MSISDN, typ, price)
|
add_dict(MSISDN, typ, price)
|
||||||
if row['Jednotka'] == "ks":
|
if row['Jednotka'] == "ks":
|
||||||
#print("pricesms: ", pricesms, " for unit: ", dictionary[MSISDN])
|
|
||||||
add_dictsms(MSISDN, pricesms)
|
add_dictsms(MSISDN, pricesms)
|
||||||
|
|
||||||
|
if row['Jednotka'] == "kB":
|
||||||
|
add_dictdataamount(MSISDN, dataamount)
|
||||||
|
|
||||||
|
|
||||||
#try:
|
#try:
|
||||||
@@ -165,11 +181,12 @@ with open('output_TMCZ_'+ext_date_from_filaname, 'w') as f:
|
|||||||
sms = dictionary[key]['sms']
|
sms = dictionary[key]['sms']
|
||||||
other = dictionary[key]['other']
|
other = dictionary[key]['other']
|
||||||
smscount = dictionary[key]['smscount']
|
smscount = dictionary[key]['smscount']
|
||||||
|
dataamount = dictionary[key]['dataamount']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
writer.writerow([key, "N/A", "N/A", data, "N/A", sms, "N/A", other, "N/A"])
|
writer.writerow([key, "N/A", "N/A", data, dataamount, sms, smscount, other, "N/A"])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user