Updated script to handle HOIP (replacement for Hamshack Hotline).
This commit is contained in:
parent
ac8ecbdda4
commit
f75cc6f475
1 changed files with 34 additions and 28 deletions
|
|
@ -88,18 +88,18 @@ checkins_df["Date"] = pd.to_datetime(checkins_df["Date"]).dt.strftime('%Y-%m-%d'
|
||||||
callinfo_df = pd.read_excel(xls, "Call_Data", dtype=str)
|
callinfo_df = pd.read_excel(xls, "Call_Data", dtype=str)
|
||||||
#print("callinfo_df:")
|
#print("callinfo_df:")
|
||||||
#print(callinfo_df)
|
#print(callinfo_df)
|
||||||
hh_dir_df = pd.read_excel(xls, "Hamshack_Hotline", dtype=str)
|
hoip_dir_df = pd.read_excel(xls, "hoip_subscribers", dtype=str)
|
||||||
#print("hh_dir_df:")
|
#print("hoip_dir_df:")
|
||||||
#print(hh_dir_df)
|
#print(hoip_dir_df)
|
||||||
|
|
||||||
# build dictionary of HH phone numbers
|
# build dictionary of HH phone numbers
|
||||||
hh_phone_dict = {"Callsign" : "HH Number"}
|
hoip_phone_dict = {"Callsign" : "HH Number"}
|
||||||
for i,row in hh_dir_df.iterrows():
|
for i,row in hoip_dir_df.iterrows():
|
||||||
callsign = row.iloc[1]
|
callsign = row.iloc[1]
|
||||||
hh_num = row.iloc[7]
|
hoip_num = row.iloc[0]
|
||||||
# we only add the hh number first seen for a unique callsign
|
# we only add the hoip number first seen for a unique callsign
|
||||||
if callsign not in hh_phone_dict.keys():
|
if callsign not in hoip_phone_dict.keys():
|
||||||
hh_phone_dict.update({callsign : hh_num})
|
hoip_phone_dict.update({callsign : hoip_num})
|
||||||
|
|
||||||
# fill in any missing data (NAN's) with default text
|
# fill in any missing data (NAN's) with default text
|
||||||
callinfo_df.fillna({'Name' : ''}, inplace=True)
|
callinfo_df.fillna({'Name' : ''}, inplace=True)
|
||||||
|
|
@ -127,27 +127,27 @@ for i,row in checkins_df.iterrows():
|
||||||
# build dictionary of call info indexed by callsign
|
# build dictionary of call info indexed by callsign
|
||||||
call_data_dict = {}
|
call_data_dict = {}
|
||||||
for i,row in callinfo_df.iterrows():
|
for i,row in callinfo_df.iterrows():
|
||||||
# row of data is call, name, state, district, county, affiliation, hh_num
|
# row of data is call, name, state, district, county, affiliation, hoip_num
|
||||||
# dictionary becomes: { call: [name[0], state[1], district[2], county[3], affiliation[4]], hh_num[5]}
|
# dictionary becomes: { call: [name[0], state[1], district[2], county[3], affiliation[4]], hoip_num[5]}
|
||||||
callsign = row.iloc[0]
|
callsign = row.iloc[0]
|
||||||
if callsign in hh_phone_dict.keys():
|
if callsign in hoip_phone_dict.keys():
|
||||||
hh_num = hh_phone_dict[callsign]
|
hoip_num = hoip_phone_dict[callsign]
|
||||||
else:
|
else:
|
||||||
hh_num = ""
|
hoip_num = ""
|
||||||
call_data_dict.update({callsign:[row.iloc[1],row.iloc[2],row.iloc[3],row.iloc[4],row.iloc[5],hh_num]})
|
call_data_dict.update({callsign:[row.iloc[1],row.iloc[2],row.iloc[3],row.iloc[4],row.iloc[5],hoip_num]})
|
||||||
|
|
||||||
# build checkin_form_dict dictionary
|
# build checkin_form_dict dictionary
|
||||||
checkin_form_dict = blank_checkin_form_dict
|
checkin_form_dict = blank_checkin_form_dict
|
||||||
for call in call_data_dict.keys():
|
for call in call_data_dict.keys():
|
||||||
#print("Looking at:", call)
|
#print("Looking at:", call)
|
||||||
#if call in hh_phone_dict.keys():
|
#if call in hoip_phone_dict.keys():
|
||||||
#print("Call "+call+" has HH VOIP #"+hh_phone_dict[call])
|
#print("Call "+call+" has HOIP #"+hoip_phone_dict[call])
|
||||||
call_state = call_data_dict[call][1]
|
call_state = call_data_dict[call][1]
|
||||||
call_dist = call_data_dict[call][2]
|
call_dist = call_data_dict[call][2]
|
||||||
call_county = call_data_dict[call][3]
|
call_county = call_data_dict[call][3]
|
||||||
call_affil = call_data_dict[call][4]
|
call_affil = call_data_dict[call][4]
|
||||||
call_hh_num = call_data_dict[call][5]
|
call_hoip_num = call_data_dict[call][5]
|
||||||
#print("State, Dist, Cnty, Affil, HH Num: ", call_state, call_dist, call_county, call_affil, call_hh_num)
|
#print("State, Dist, Cnty, Affil, HH Num: ", call_state, call_dist, call_county, call_affil, call_hoip_num)
|
||||||
|
|
||||||
# sanity check the data - error if not found in dictionary keys...
|
# sanity check the data - error if not found in dictionary keys...
|
||||||
# print("Verifying at: ", call, call_state, call_dist, call_county)
|
# print("Verifying at: ", call, call_state, call_dist, call_county)
|
||||||
|
|
@ -218,8 +218,8 @@ with open(output_file,"w") as outfile:
|
||||||
checkin_str = ""
|
checkin_str = ""
|
||||||
if checkin_count > 0:
|
if checkin_count > 0:
|
||||||
outfile.write(" "+call+", "+call_name+checkin_str)
|
outfile.write(" "+call+", "+call_name+checkin_str)
|
||||||
if call in hh_phone_dict.keys():
|
if call in hoip_phone_dict.keys():
|
||||||
outfile.write(", HH VOIP #"+hh_phone_dict[call])
|
outfile.write(", HOIP #"+hoip_phone_dict[call])
|
||||||
if call_affil != "":
|
if call_affil != "":
|
||||||
outfile.write(", "+call_affil+"\n")
|
outfile.write(", "+call_affil+"\n")
|
||||||
else:
|
else:
|
||||||
|
|
@ -237,8 +237,8 @@ with open(output_file,"w") as outfile:
|
||||||
checkin_str = ""
|
checkin_str = ""
|
||||||
if checkin_count > 0:
|
if checkin_count > 0:
|
||||||
outfile.write(" "+call+", "+call_data_dict[call][0]+checkin_str)
|
outfile.write(" "+call+", "+call_data_dict[call][0]+checkin_str)
|
||||||
if call in hh_phone_dict.keys():
|
if call in hoip_phone_dict.keys():
|
||||||
outfile.write(", HH VOIP #"+hh_phone_dict[call])
|
outfile.write(", HOIP #"+hoip_phone_dict[call])
|
||||||
affil = call_data_dict[call][4]
|
affil = call_data_dict[call][4]
|
||||||
if affil != '':
|
if affil != '':
|
||||||
outfile.write(", "+affil+"\n")
|
outfile.write(", "+affil+"\n")
|
||||||
|
|
@ -263,8 +263,8 @@ with open(output_file,"w") as outfile:
|
||||||
checkin_count = 0
|
checkin_count = 0
|
||||||
checkin_str = ""
|
checkin_str = ""
|
||||||
outfile.write(" "+call+", "+call_data_dict[call][0]+checkin_str)
|
outfile.write(" "+call+", "+call_data_dict[call][0]+checkin_str)
|
||||||
if call in hh_phone_dict.keys():
|
if call in hoip_phone_dict.keys():
|
||||||
outfile.write(", HH VOIP #"+hh_phone_dict[call])
|
outfile.write(", HOIP #"+hoip_phone_dict[call])
|
||||||
affil = call_data_dict[call][4]
|
affil = call_data_dict[call][4]
|
||||||
if affil != '':
|
if affil != '':
|
||||||
outfile.write(", "+affil+"\n")
|
outfile.write(", "+affil+"\n")
|
||||||
|
|
@ -367,8 +367,10 @@ for net_day in net_day_list:
|
||||||
cur_call_list.sort()
|
cur_call_list.sort()
|
||||||
for call in cur_call_list:
|
for call in cur_call_list:
|
||||||
affil = call_data_dict[call][4]
|
affil = call_data_dict[call][4]
|
||||||
hh_num = call_data_dict[call][5]
|
hoip_num = call_data_dict[call][5]
|
||||||
outfile.write(" "+call+", "+call_data_dict[call][0])
|
outfile.write(" "+call+", "+call_data_dict[call][0])
|
||||||
|
if hoip_num != '':
|
||||||
|
outfile.write(", HOIP #"+hoip_num)
|
||||||
if affil != '':
|
if affil != '':
|
||||||
outfile.write(", "+affil+"\n")
|
outfile.write(", "+affil+"\n")
|
||||||
else:
|
else:
|
||||||
|
|
@ -380,8 +382,10 @@ for net_day in net_day_list:
|
||||||
cur_call_list.sort()
|
cur_call_list.sort()
|
||||||
for call in cur_call_list:
|
for call in cur_call_list:
|
||||||
affil = call_data_dict[call][4]
|
affil = call_data_dict[call][4]
|
||||||
hh_num = call_data_dict[call][5]
|
hoip_num = call_data_dict[call][5]
|
||||||
outfile.write(" "+call+", "+call_data_dict[call][0])
|
outfile.write(" "+call+", "+call_data_dict[call][0])
|
||||||
|
if hoip_num != '':
|
||||||
|
outfile.write(", HOIP #"+hoip_num)
|
||||||
if affil != '':
|
if affil != '':
|
||||||
outfile.write(", "+affil+"\n")
|
outfile.write(", "+affil+"\n")
|
||||||
else:
|
else:
|
||||||
|
|
@ -397,8 +401,10 @@ for net_day in net_day_list:
|
||||||
cur_call_list.sort()
|
cur_call_list.sort()
|
||||||
for call in cur_call_list:
|
for call in cur_call_list:
|
||||||
affil = call_data_dict[call][4]
|
affil = call_data_dict[call][4]
|
||||||
hh_num = call_data_dict[call][5]
|
hoip_num = call_data_dict[call][5]
|
||||||
outfile.write(" "+call+", "+call_data_dict[call][0])
|
outfile.write(" "+call+", "+call_data_dict[call][0])
|
||||||
|
if hoip_num != '':
|
||||||
|
outfile.write(", HOIP #"+hoip_num)
|
||||||
if affil != '':
|
if affil != '':
|
||||||
outfile.write(", "+affil+"\n")
|
outfile.write(", "+affil+"\n")
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue