Compare commits
4 Commits
4ef0291dbd
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 6bab0a4a12 | |||
| e2e795bf3b | |||
| e82354b3ab | |||
| 0ce38b22fd |
@@ -20,8 +20,7 @@ FILE = FILE[0]
|
|||||||
ext_date_from_filaname = FILE.split('_')[-1]
|
ext_date_from_filaname = FILE.split('_')[-1]
|
||||||
print(ext_date_from_filaname)
|
print(ext_date_from_filaname)
|
||||||
|
|
||||||
#usrmonth = input("Month to be processed: ")
|
|
||||||
#usrmonth = int(usrmonth)
|
|
||||||
usrmonth = int(5)
|
usrmonth = int(5)
|
||||||
|
|
||||||
dictionary = {}
|
dictionary = {}
|
||||||
@@ -56,44 +55,15 @@ with open(FILE, newline='', encoding="utf-8") as csvfile:
|
|||||||
reader = csv.DictReader(csvfile, delimiter=';',fieldnames=['faktura_c','phonenumber','direction','productgroup','productser','item','service','datetime','dialnum','time_taken','time_charged','dataamount','realcost','creditcost','discount' 'servicescost','chargedwovat','chargedwvat','privatecall'])
|
reader = csv.DictReader(csvfile, delimiter=';',fieldnames=['faktura_c','phonenumber','direction','productgroup','productser','item','service','datetime','dialnum','time_taken','time_charged','dataamount','realcost','creditcost','discount' 'servicescost','chargedwovat','chargedwvat','privatecall'])
|
||||||
for row in reader:
|
for row in reader:
|
||||||
print("Product serie: ",row['productser'])
|
print("Product serie: ",row['productser'])
|
||||||
|
|
||||||
print("Time taken ",row['time_taken'])
|
print("Time taken ",row['time_taken'])
|
||||||
# sys.exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
#print(row)
|
|
||||||
if row['phonenumber'] == '':
|
if row['phonenumber'] == '':
|
||||||
continue #skip empty phonenumber
|
continue #skip empty phonenumber
|
||||||
# if row['Začátek fakturačního období'] == '':
|
|
||||||
# continue
|
|
||||||
#
|
|
||||||
# my_string = row['Začátek fakturačního období']
|
|
||||||
# #my_string = '2021-09-06'
|
|
||||||
# print("start date: ",my_string)
|
|
||||||
#
|
|
||||||
# try:
|
|
||||||
# my_date = datetime.strptime(my_string, "%d.%m.%Y")
|
|
||||||
# except:
|
|
||||||
# print("An exception occurred, current my_string is: ", my_string)
|
|
||||||
# sys.exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
#print(row['BILLED_PERIOD_START'])
|
|
||||||
#print(my_date.month)
|
|
||||||
|
|
||||||
|
|
||||||
# if usrmonth != my_date.month:
|
|
||||||
# print("skipping bad date")
|
|
||||||
# continue #skip bad dates
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MSISDN = int(row['phonenumber'])
|
MSISDN = int(row['phonenumber'])
|
||||||
#ICCID = int(row['ICCID'])
|
|
||||||
price = row['chargedwovat'].replace(',','.')
|
|
||||||
|
|
||||||
#price = round(price, 5)
|
price = row['chargedwovat'].replace(',','.')
|
||||||
|
|
||||||
typ = None
|
typ = None
|
||||||
|
|
||||||
@@ -106,8 +76,6 @@ with open(FILE, newline='', encoding="utf-8") as csvfile:
|
|||||||
typ = 'other'
|
typ = 'other'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if row['direction'] != "I" and row['productser'] == "SMS ":
|
if row['direction'] != "I" and row['productser'] == "SMS ":
|
||||||
|
|
||||||
pricesms = int(row['time_taken'])
|
pricesms = int(row['time_taken'])
|
||||||
@@ -136,18 +104,6 @@ with open(FILE, newline='', encoding="utf-8") as csvfile:
|
|||||||
print("direction: ", row['direction'], " and productser: ", row['productser'])
|
print("direction: ", row['direction'], " and productser: ", row['productser'])
|
||||||
|
|
||||||
|
|
||||||
#try:
|
|
||||||
#print(dictionary[436761890319959]) #one with both types
|
|
||||||
#except:
|
|
||||||
#print("Required unit is not in our set")
|
|
||||||
#sys.exit(1)
|
|
||||||
|
|
||||||
#print(len(dictionary.keys()))
|
|
||||||
|
|
||||||
#for key, value in dictionary.items():
|
|
||||||
#print(key, ' : ', value)
|
|
||||||
|
|
||||||
|
|
||||||
print("Count of units: ", len(dictionary.keys()))
|
print("Count of units: ", len(dictionary.keys()))
|
||||||
|
|
||||||
|
|
||||||
@@ -155,7 +111,7 @@ print("Count of units: ", len(dictionary.keys()))
|
|||||||
with open('output_VFCZ_'+ext_date_from_filaname, 'w') as f:
|
with open('output_VFCZ_'+ext_date_from_filaname, 'w') as f:
|
||||||
|
|
||||||
writer = csv.writer(f)
|
writer = csv.writer(f)
|
||||||
writer.writerow(["MSISDN","ICCID","IMSI","DATA-PRICE","DATA-AMOUNT","SMS-PRICE","SMS-COUNT","OTHER-PRICE","SIM-STATUS"])
|
writer.writerow(["MSISDN","ICCID","IMSI","DATA-PRICE","DATA-AMOUNT","SMS-PRICE","SMS-COUNT","OTHER-PRICE","SIM-STATUS","OPERATOR"])
|
||||||
for key in dictionary.keys():
|
for key in dictionary.keys():
|
||||||
print(key)
|
print(key)
|
||||||
print(dictionary[key])
|
print(dictionary[key])
|
||||||
@@ -167,29 +123,10 @@ with open('output_VFCZ_'+ext_date_from_filaname, 'w') as f:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
writer.writerow([key, "N/A", "N/A", round(float(data)), round(float(dataamount), 2), sms, smscount, other, "N/A"])
|
writer.writerow([key, "N/A", "N/A", round(float(data)), round(float(dataamount), 2), sms, smscount, other, "N/A", "VFCZ"])
|
||||||
|
|
||||||
|
|
||||||
with open('output_VFCZ_'+ext_date_from_filaname, "rb") as f:
|
with open('output_VFCZ_'+ext_date_from_filaname, "rb") as f:
|
||||||
webhook.add_file(file=f.read(), filename='output_VFCZ_'+ext_date_from_filaname)
|
webhook.add_file(file=f.read(), filename='output_VFCZ_'+ext_date_from_filaname)
|
||||||
|
|
||||||
response = webhook.execute()
|
response = webhook.execute()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#csv_columns = ['takhleuztoneudelam', 'data', 'sms', 'other', 'smscount', 'dataamount']
|
|
||||||
#try:
|
|
||||||
# with open('export_vd_202109v1.csv', 'w') as csvfile:
|
|
||||||
# w = csv.DictWriter(sys.stdout, csv_columns)
|
|
||||||
# for key, val in sorted(dictionary.items()):
|
|
||||||
# row = {'takhleuztoneudelam': key}
|
|
||||||
# row.update(val)
|
|
||||||
|
|
||||||
# writer = csv.DictWriter(csvfile, fieldnames=csv_columns)
|
|
||||||
# writer.writerow(row)
|
|
||||||
|
|
||||||
#except IOError:
|
|
||||||
# print(f"I/O error: {IOError}")
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user