converted colons, merge updated
This commit is contained in:
76
main.py
76
main.py
@@ -13,22 +13,27 @@ outvar = {}
|
||||
|
||||
"""
|
||||
def merge():
|
||||
interesting_files = glob.glob("./output/*.csv")
|
||||
interesting_files = glob.glob("./output/*.csv")
|
||||
df = pd.concat((pd.read_csv(f, header = 0) for f in interesting_files))
|
||||
df.to_csv("./output/global_output.csv",index=False,index_label=None,columns=None)
|
||||
"""
|
||||
def convertChars(val):
|
||||
converted = val.replace(',', '')
|
||||
converted = converted.replace('.', ',')
|
||||
return converted
|
||||
|
||||
|
||||
def merge():
|
||||
dirpath = "./output/"
|
||||
tmgdspfile = [filename for filename in os.listdir(dirpath) if filename.startswith("output_TMGDSP_")]
|
||||
tmgdspfile = tmgdspfile[0]
|
||||
|
||||
|
||||
vfgdspfile = [filename for filename in os.listdir(dirpath) if filename.startswith("output_VFGDSP_")]
|
||||
vfgdspfile = vfgdspfile[0]
|
||||
|
||||
|
||||
tmczfile = [filename for filename in os.listdir(dirpath) if filename.startswith("output_TMCZ_")]
|
||||
tmczfile = tmczfile[0]
|
||||
|
||||
|
||||
vfczfile = [filename for filename in os.listdir(dirpath) if filename.startswith("output_VFCZ_")]
|
||||
vfczfile = vfczfile[0]
|
||||
|
||||
@@ -80,8 +85,8 @@ def merge():
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
print("created dict to translate sns")
|
||||
|
||||
@@ -91,13 +96,13 @@ def merge():
|
||||
print("got into reader func")
|
||||
with open('./output/output_testmerge.csv', 'w', newline='', encoding="utf-8") as f:
|
||||
writer = csv.writer(f)
|
||||
|
||||
|
||||
for row in reader:
|
||||
print(row)
|
||||
msisdn = int(row['MSISDN'])
|
||||
print(type(msisdn))
|
||||
print(msisdn)
|
||||
|
||||
|
||||
if msisdn in convert_tmcz:
|
||||
print("msisdn found in helper, we have iccid and imsi")
|
||||
iccid = convert_tmcz[msisdn]['iccid']
|
||||
@@ -106,8 +111,6 @@ def merge():
|
||||
|
||||
imsitoconvert = int(imsi)
|
||||
|
||||
|
||||
|
||||
#print(serialnumberdict[int(imsitoconvert)]['sn'])
|
||||
if imsitoconvert in serialnumberdict:
|
||||
print("found in snhelper, can convert to sn")
|
||||
@@ -119,10 +122,6 @@ def merge():
|
||||
realsn = "unknown"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
else:
|
||||
print("msisdn not found in helper, we dont have iccid and imsi")
|
||||
iccid = "N/A"
|
||||
@@ -137,7 +136,7 @@ def merge():
|
||||
simstatus = row['SIM-STATUS']
|
||||
operator = row['OPERATOR']
|
||||
print("realsn: ",realsn)
|
||||
writer.writerow([msisdn, iccid, imsi, dataprice, dataamount, smsprice, smscount, otherprice, simstatus, realsn, operator])
|
||||
writer.writerow([msisdn, iccid, imsi, convertChars(dataprice), convertChars(dataamount), convertChars(smsprice), convertChars(smscount), convertChars(otherprice), simstatus, realsn, operator])
|
||||
print("Merged")
|
||||
|
||||
with open(dirpath+vfczfile, newline='', encoding="utf-8") as csvfile:
|
||||
@@ -146,7 +145,7 @@ def merge():
|
||||
print("got into reader func")
|
||||
with open(dirpath+'output_testmerge.csv', 'a', newline='', encoding="utf-8") as f:
|
||||
writer = csv.writer(f)
|
||||
for row in reader:
|
||||
for row in reader:
|
||||
print(row)
|
||||
msisdn = int(row['MSISDN'])
|
||||
dataprice = row['DATA-PRICE']
|
||||
@@ -156,7 +155,7 @@ def merge():
|
||||
otherprice = row['OTHER-PRICE']
|
||||
simstatus = row['SIM-STATUS']
|
||||
operator = row['OPERATOR']
|
||||
writer.writerow([msisdn, iccid, imsi, dataprice, dataamount, smsprice, smscount, otherprice, simstatus, operator])
|
||||
writer.writerow([msisdn, iccid, imsi, convertChars(dataprice), convertChars(dataamount), convertChars(smsprice), convertChars(smscount), convertChars(otherprice), simstatus, "unknown",operator])
|
||||
|
||||
|
||||
with open(dirpath+vfgdspfile, newline='', encoding="utf-8") as csvfile:
|
||||
@@ -165,9 +164,25 @@ def merge():
|
||||
print("got into reader func")
|
||||
with open(dirpath+'output_testmerge.csv', 'a', newline='', encoding="utf-8") as f:
|
||||
writer = csv.writer(f)
|
||||
for row in reader:
|
||||
for row in reader:
|
||||
print(row)
|
||||
msisdn = int(row['MSISDN'])
|
||||
iccid = int(row['ICCID'])
|
||||
imsi = int(row['IMSI'])
|
||||
|
||||
# grab sn from helper
|
||||
|
||||
|
||||
if imsi in serialnumberdict:
|
||||
print("found in snhelper, can convert to sn")
|
||||
realsn = serialnumberdict[int(imsi)]['sn']
|
||||
print(realsn)
|
||||
|
||||
|
||||
else:
|
||||
print("msisdn not found in helper, we dont have sn")
|
||||
realsn = "unknown"
|
||||
|
||||
dataprice = row['DATA-PRICE']
|
||||
dataamount = row['DATA-AMOUNT']
|
||||
smsprice = row['SMS-PRICE']
|
||||
@@ -175,7 +190,7 @@ def merge():
|
||||
otherprice = row['OTHER-PRICE']
|
||||
simstatus = row['SIM-STATUS']
|
||||
operator = row['OPERATOR']
|
||||
writer.writerow([msisdn, iccid, imsi, dataprice, dataamount, smsprice, smscount, otherprice, simstatus, operator])
|
||||
writer.writerow([msisdn, iccid, imsi, convertChars(dataprice), convertChars(dataamount), convertChars(smsprice), convertChars(smscount), convertChars(otherprice), simstatus, realsn, operator])
|
||||
|
||||
with open(dirpath+tmgdspfile, newline='', encoding="utf-8") as csvfile:
|
||||
reader = csv.DictReader(csvfile, delimiter=',')
|
||||
@@ -183,9 +198,24 @@ def merge():
|
||||
print("got into reader func")
|
||||
with open(dirpath+'output_testmerge.csv', 'a', newline='', encoding="utf-8") as f:
|
||||
writer = csv.writer(f)
|
||||
for row in reader:
|
||||
for row in reader:
|
||||
print(row)
|
||||
msisdn = int(row['MSISDN'])
|
||||
iccid = int(row['ICCID'])
|
||||
imsi = int(row['IMSI'])
|
||||
# grab sn from helper
|
||||
|
||||
|
||||
if imsi in serialnumberdict:
|
||||
print("found in snhelper, can convert to sn")
|
||||
realsn = serialnumberdict[int(imsi)]['sn']
|
||||
print(realsn)
|
||||
|
||||
else:
|
||||
print("msisdn not found in helper, we dont have sn")
|
||||
realsn = "unknown"
|
||||
|
||||
|
||||
dataprice = row['DATA-PRICE']
|
||||
dataamount = row['DATA-AMOUNT']
|
||||
smsprice = row['SMS-PRICE']
|
||||
@@ -193,7 +223,7 @@ def merge():
|
||||
otherprice = row['OTHER-PRICE']
|
||||
simstatus = row['SIM-STATUS']
|
||||
operator = row['OPERATOR']
|
||||
writer.writerow([msisdn, iccid, imsi, dataprice, dataamount, smsprice, smscount, otherprice, simstatus, operator])
|
||||
writer.writerow([msisdn, iccid, imsi, convertChars(dataprice), convertChars(dataamount), convertChars(smsprice), convertChars(smscount), convertChars(otherprice), simstatus,realsn ,operator])
|
||||
|
||||
print("succesfuly merged")
|
||||
|
||||
@@ -305,7 +335,7 @@ def runBilling():
|
||||
ret = sp.call(["python", "tmgdsp.py"])
|
||||
if ret != 0:
|
||||
raw_input()
|
||||
|
||||
|
||||
ret = sp.call(["python", "vfgdsp_final.py"])
|
||||
if ret != 0:
|
||||
raw_input()
|
||||
@@ -420,4 +450,4 @@ b3.grid(row=6, column=2)
|
||||
b4.grid(row=7, column=2)
|
||||
|
||||
root.after(0, checkFiles)
|
||||
tk.mainloop()
|
||||
tk.mainloop()
|
||||
Reference in New Issue
Block a user