Update iterate_xlsx.py

This commit is contained in:
Andrean
2022-04-22 18:57:30 +03:00
committed by GitHub
parent a07662ce65
commit 083e184fbe
+188 -158
View File
@@ -8,6 +8,8 @@ working_dir_json = join(working_dir, 'Jsons')
working_dir_xlsx = join(working_dir, 'XLSX')
working_dir_sorted = join(working_dir, 'Sorted')
os.chdir(working_dir)
def rename_files(name_to_be_ranamed):
"""
@@ -61,6 +63,8 @@ def operate_cwd_old(work_on):
remove_request_trace(name)
get_service_names(name)
replace_service_names(name)
if os.path.exists(join(working_dir_json, "service_names.txt")):
os.replace(join(working_dir_json, "service_names.txt"), join(working_dir, "service_names.txt"))
parametrize_payload(name)
if work_on == 'json':
for root, dirs, files in os.walk(working_dir_json, topdown=False):
@@ -99,64 +103,34 @@ def insert_in_nvar(size_to_match, string_to_insert, modified_list):
modified_list = modified_list + [string_to_insert]
return modified_list
def read_params_from_file(file_name,list_tmp):
with open(file_name, 'r') as file:
for line in file:
line = line.strip('\n')
line = f'{line}'
list_tmp.append(line)
return list_tmp
def replace_var_value(ws, name_working):
"""
Parametrazis the excels and json files.
"""
ICCID = ['89470311210210000681', "89470311210210000699", "89470311210210000707", "89470311210210000715",
"89470311210210000723", "89470311210210000731", "89470311210210000749", "89470311210210000756",
"89470311210210000764", "89470311210210000772", "89470311210210000780", "89470311210210000798",
"89470311210210000806", "89470311210210000814", "89470311210210000822", "89470311210210000830",
"89470311210210000996", "89470000190625003999", "89470000190625003981", "89470000190625003973",
"89470000190625003965", "89470000190625003957", "89470000190625003940", "89470000190625003932",
"89470000190625003924", "89470000190625003890", "89470000190625003882", "89470000190625003874",
"89470000190625003866", "89470000190625003825", "89470000190625003817", "89470000190625003809",
"89470000190625003791", "89470311210210000962", "89470311210210000970", "89470311210210000988"]
IMSI = ["242013083407751", "242013083407752", "242013083407753", "242013083407754", "242013083407758",
"242013083407759", "242013083407760", "242013083407771", "242013083407764", "242013083407765",
"242013083407766", "242013083407767", "242013083407768", "242013083407769", "242013083407770",
"242013083407771", "242013083407762", "242013083407763", "242013083407757", "242013083407756",
"242013083407755", "242013112998926", "242013112998927", "242013112998928", "242013112998929",
"242013112998930", "242013112998931", "242013112998932", "242013112998933", "242013112998934",
"242013112998935", "242013112998936", "242013112998937", "242013112998938", "242013112998939",
"242013112998940", "242013112998941", "242013112998942", "242013112998943", "242013112998944",
"242013112998945", "242013112998946", "242013112998947", "242013112998948", "242013112998949",
"242013112998962", "242013112998963", "242013112998964", "242013112998965"]
order_subsceriber_desc = ["580002010006", "580002010007", "580002010008", "580002010009", "580002010010",
"580002010011", "580002010012", "580002010013", "580002010005", "580002010014",
"580002010015", "580002010016", "580002010017", "580002010018", "580002010019",
"580002010020", "580004217291", "580004217292", "580004217293", "580004217294",
"580004217295", "580004217296", "580004217297", "580004217298", "580004217299",
"580000001404", "580002150328", "580002150990", "580002150964", "580002150963",
"580002150960", "580002150712", "580002150388", "580002150328", "580002150304",
"580002150290", "580002150284", "99899862", "99899824", "99899548", "99899499",
"99899444", "99898929", "99898689", "99897498", "99897152", "99896844", "580000084347",
"580000051184", "580000041302", "580000041274", "580000041270", "580000015006",
"580000010850", "580000001404", "580000000972", "580000000304", "99792775", "99749252",
"99748432", "99741336", "99723770", "99721033", "99640312", "99628853", "99617374",
"99547073", ]
order_subscriber_id = ["41147337", "41186302", "41147373", "41135924", "41171632", "41171641", "41171646",
"41171647", "41135929", "51547639", "34572037", "34944493", "34174958", "37210572",
"43927785", "35019217", "48505103", "38865130", "34723909", "51593973", "46308554",
"44838652", "50569389", "44906460", "35178340", "43997935", "41559450", '20929630',
'47989748', '48270620', '47988315', '47989812', '48271069', '47987444', '47990536',
'47990098', '48270844', '51751826', '51751842', '51751847', '48270280', '29410992',
'48207456', '48207305', '48207327', '48537495', '47485638', '51709328', '40737621',
'45588396', '50335525', '41713772', '50177158', '46447744', '48643763', '46705964',
'45927525', '42647761', '42651740', '42653822', '42648906', '42652680', '42652015',
'42994967', '42995459', '42995945', '42995341']
ICCID = []
IMSI = []
order_subsceriber_desc = []
order_subscriber_id = []
service_name = []
with open('service_names.txt', 'r') as file:
for line in file:
line = line.strip('\n')
line = f'"{line}"'
service_name.append(line)
os.chdir(join(working_dir, 'configuration'))
order_subsceriber_desc=read_params_from_file('order_subscriber_desc.txt',order_subsceriber_desc)
order_subscriber_id=read_params_from_file('order_subscriber_id.txt', order_subscriber_id)
ICCID = read_params_from_file('iccid.txt', ICCID)
IMSI = read_params_from_file('imsi.txt', IMSI)
service_name = read_params_from_file('service_names.txt', service_name)
system_component_id = ['pcrf_1384193797', "pcrf_1084193793", "RoamingZone", ]
valid_to_date = ['05-09-2022']
roaming_zone = ['RZ1']
o_var = order_subsceriber_desc + order_subscriber_id + service_name + system_component_id + valid_to_date + roaming_zone + ICCID + IMSI
n_var = []
n_var = insert_in_nvar(order_subsceriber_desc, '${ORDER_SUBSCRIBER_DESC}', n_var)
@@ -187,7 +161,7 @@ def replace_in_json(name_working, o_var, n_var):
def replace_in_xls(ws, old_var, new_var):
"""
Parametrize the JSON file
Parametrize the XLS file
"""
if not ws:
return
@@ -313,7 +287,7 @@ def sort_files(work_on):
Sorts the payload files into Subscribers
"""
wd = False
groups = ["PostPaid_CON", "PostPaid_BUS", "PostPaid_SP", "LTE", "PrePaid_SP", "PrePaid", "M2M"]
groups = ["PostPaid_CON", "PostPaid_BUS", "PostPaid_SP", "LTE", "PrePaid_SP", "PrePaid", "M2M", "IPT", "VOICETWIN"]
if work_on == 'json':
wd = working_dir_json
@@ -327,52 +301,55 @@ def sort_files(work_on):
os.chdir(wd)
for group in groups:
if re.search(group, name):
os.replace(join(wd, name),
join(working_dir_sorted, group, name))
try:
os.replace(join(wd, name), join(working_dir_sorted, group, name))
except:
pass
def give_number_to_files(starting_number):
"""
Renames files in the current working directory directory to be sorted in order and in create delete pairs
"""
i = starting_number
for root, dirs, files in os.walk(working_dir_sorted, topdown=False):
for root, dirs, files in os.walk(working_dir, topdown=False):
file_names = files
k = 0
os.chdir(root)
while k < len(file_names) and i < len(file_names) + starting_number:
j = 0
while j < len(file_names):
if file_names[k][6:] == file_names[j][6:] and k != j:
try:
if i < 9:
os.rename(file_names[k], '000' + str(i) + file_names[k])
os.rename(file_names[j], '000' + str(i + 1) + file_names[j])
elif i == 9:
os.rename(file_names[k], '000' + str(i) + file_names[k])
os.rename(file_names[j], '00' + str(i + 1) + file_names[j])
else:
os.rename(file_names[k], '00' + str(i) + file_names[k])
os.rename(file_names[j], '00' + str(i + 1) + file_names[j])
i += 2
except OSError as err:
print(err.errno)
break
j += 1
k += 1
break
i = starting_number
if root == working_dir:
while k < len(file_names) and i < len(file_names) + starting_number:
j = 0
while j < len(file_names):
if file_names[k][6:] == file_names[j][6:] and k != j:
try:
if i < 9:
os.rename(file_names[k], '000' + str(i) + file_names[k])
os.rename(file_names[j], '000' + str(i + 1) + file_names[j])
elif i == 9:
os.rename(file_names[k], '000' + str(i) + file_names[k])
os.rename(file_names[j], '00' + str(i + 1) + file_names[j])
else:
os.rename(file_names[k], '00' + str(i) + file_names[k])
os.rename(file_names[j], '00' + str(i + 1) + file_names[j])
i += 2
except OSError as err:
print(err)
break
j += 1
k += 1
def remove_number_from_files():
"""
Renames files in the current working directory directory to remove the sorting numbers
"""
os.chdir(working_dir_xlsx)
os.chdir(working_dir)
file_names = []
for root, dirs, files in os.walk(working_dir_xlsx, topdown=False):
for root, dirs, files in os.walk(working_dir, topdown=False):
file_names = files
break
if root == working_dir:
break
k = 0
while k < len(file_names):
if re.match('\d{4}', file_names[k]) is not None:
@@ -382,7 +359,7 @@ def remove_number_from_files():
def remove_request_trace(name_working):
"""
Removes the request trace parameters from the json files.
Removes the request trace part from the json files.
"""
with open(join(working_dir_json, name_working), "r") as file:
f = file.read()
@@ -393,16 +370,53 @@ def remove_request_trace(name_working):
def replace_service_names(name_working):
"""
Replaces the Service name value with ${SERVICE_NAME} in all json. Effectivly parametrizing them.
Replaces the Service name value with ${SERVICE_NAME} in all json and does the same for other common parameters
"""
with open(join(working_dir_json, name_working), "r") as file:
file_string = file.read()
service_match = re.search(r'"service":\s{\s*"id":\s"([a-zA-z0-9]*)",\s*"name":\s"([0-9]*)"', file_string)
if service_match is not None:
file_string = re.sub('"service":\s{\s*"id":\s(.*)\s*"name":\s"([0-9]*)"',
'"service": {\n "id":"%s",\n "name":"${SERVICE_NAME}"' % (
file_string = re.sub('"service":\s{\s*"id":\s"([a-zA-z0-9]*)",\s*"name":\s"([0-9]*)"',
'\t"service": {\n "id":"%s",\n \t"name":"${SERVICE_NAME}"' % (
service_match.group(1)), file_string)
service_match = re.search(
r'"serviceCharacteristic":\s\[\s*{\s*"name":\s?"116",\s*"value":\s?"([0-9]*)"\s*}\s*]', file_string)
if service_match is not None:
file_string = re.sub('"serviceCharacteristic":\s\[\s*{\s*"name":\s?"116",\s*"value":\s?"([0-9]*)"',
'\t\t"serviceCharacteristic": [{\n\t\t\t\t"name":"116",\n\t\t\t\t"value":"${ORDER_SUBSCRIBER_DESC_NEW}"',
file_string)
service_match = re.search(r'"name":\s?"6407",\s*"value":\s?"([^"]*)"', file_string)
if service_match is not None:
file_string = re.sub('"name":\s?"6407",\s*"value":\s?"([^"]*)"',
'\t\t"name":"6407",\n\t\t\t\t"value":"${MBN_AGREEMENT_ID}"',file_string)
service_match = re.search(r'"name":\s?"6875",\s*"value":\s?"([^"]*)"', file_string)
if service_match is not None:
file_string = re.sub('"name":\s?"6875",\s*"value":\s?"([^"]*)"',
'\t\t"name":"6875",\n\t\t\t\t"value":"${KURT_ID}"',file_string)
service_match = re.search(r'"name":\s?"3086",\s*"value":\s?"([^"]*)"', file_string)
if service_match is not None:
file_string = re.sub('"name":\s?"3086",\s*"value":\s?"([^"]*)"',
'\t\t"name":"3086",\n\t\t\t\t"value":"${MBN_FIRST_NAME}"',file_string)
service_match = re.search(r'"name":\s?"3087",\s*"value":\s?"([^"]*)"', file_string)
if service_match is not None:
file_string = re.sub('"name":\s?"3087",\s*"value":\s?"([^"]*)"',
'\t\t"name":"3087",\n\t\t\t\t"value":"${MBN_SECOND_NAME}"', file_string)
service_match = re.search(r'"name":\s?"6304",\s*"value":\s?"([^"]*)"', file_string)
if service_match is not None:
file_string = re.sub('"name":\s?"6304",\s*"value":\s?"([^"]*)"',
'\t\t"name":"6304",\n\t\t\t\t"value":"${MBN_EMAIL}"',file_string)
service_match = re.search(r'"name":\s?"6493",\s*"value":\s?"([^"]*)"', file_string)
if service_match is not None:
file_string = re.sub('"name":\s?"6493",\s*"value":\s?"([^"]*)"',
'\t\t"name":"6493",\n\t\t\t\t"value":"${MBN_FLAG}"', file_string)
with open(join(working_dir_json, name_working), "w") as file:
file.write(file_string)
@@ -411,7 +425,7 @@ def get_service_names(file_name):
"""
Reads the service name from the json files and prints them to the screen.
"""
os.chdir(working_dir_json)
os.chdir(working_dir)
with open(join(working_dir_json, file_name), "r") as file:
file_string = file.read()
service_match = re.search(r'"service":\s{\s*"id":\s"([a-zA-z0-9]*)",\s*"name":\s"([0-9]*)"', file_string)
@@ -424,42 +438,42 @@ def get_service_names(file_name):
def parametrize_payload(name_working):
"""
Parametrizes the payload with the default values
Parametrizes the payload with the default values for the subscriber it dose not replace the values for the service
"""
with open(join(working_dir_json, name_working), "r") as file:
file_string = file.read()
file_string = re.sub('"externalId":\s"([^"]*)"', '"externalId": "${externalId}"', file_string)
file_string = re.sub('"orderDate":\s"([^"]*)"', '"orderDate": "${orderDate}"', file_string)
file_string = re.sub('"orderType":\s"([^"]*)"', '"orderType": "${orderType}"', file_string)
file_string = re.sub('"externalId":\s?"([^"]*)"', '"externalId": "${externalId}"', file_string)
file_string = re.sub('"orderDate":\s?"([^"]*)"', '"orderDate": "${orderDate}"', file_string)
file_string = re.sub('"orderType":\s?"([^"]*)"', '"orderType": "${orderType}"', file_string)
match = re.search(r'"AsyncResponse":\s{[\s\S]*"replyToAddress":\s"([^"]*)"', file_string)
match = re.search(r'"AsyncResponse":\s??{[\s\S]*"replyToAddress":\s?"([^"]*)"', file_string)
file_string = re.sub(match.group(1), '${AsyncResponse_replyToAddress}', file_string)
match = re.search(r'"WSSec":\s{[\s\S]*"username":\s"([^"]*)"', file_string)
match = re.search(r'"WSSec":\s?{[\s\S]*"username":\s?"([^"]*)"', file_string)
file_string = re.sub(match.group(1), '${WSSec_username}', file_string)
match = re.search(r'"WSSec":\s{[\s\S]*"password":\s"([^"]*)"', file_string)
match = re.search(r'"WSSec":\s?{[\s\S]*"password":\s?"([^"]*)"', file_string)
file_string = re.sub(match.group(1), '${WSSec_password}', file_string)
match = re.search(r'"OMRequestSpec":\s{[\s\S]*"neType":\s"([^"]*)"', file_string)
match = re.search(r'"OMRequestSpec":\s?{[\s\S]*"neType":\s?"([^"]*)"', file_string)
file_string = re.sub(match.group(1), '${OMRequestSpec_neType}', file_string)
match = re.search(r'"name":\s"IL_REQ_GROUP",\s*"value":\s"([^"]*)"', file_string)
match = re.search(r'"name":\s?"IL_REQ_GROUP",\s*"value":\s?"([^"]*)"', file_string)
file_string = re.sub(match.group(1), '${IL_REQ_GROUP}', file_string)
match = re.search(r'"name":\s"ORDER_SUBSCRIBER_ID",\s*"value":\s"([^"]*)"', file_string)
match = re.search(r'"name":\s?"ORDER_SUBSCRIBER_ID",\s*"value":\s?"([^"]*)"', file_string)
file_string = re.sub(match.group(1), '${ORDER_SUBSCRIBER_ID}', file_string)
match = re.search(r'"name":\s"ORDER_SUBSCRIBER_DESC",\s*"value":\s"([^"]*)"', file_string)
match = re.search(r'"name":\s?"ORDER_SUBSCRIBER_DESC",\s*"value":\s?"([^"]*)"', file_string)
file_string = re.sub(match.group(1), '${ORDER_SUBSCRIBER_DESC}', file_string)
match = re.search(r'"name":\s"ORDER_SYS_ID",\s*"value":\s"([^"]*)"', file_string)
match = re.search(r'"name":\s?"ORDER_SYS_ID",\s*"value":\s?"([^"]*)"', file_string)
file_string = re.sub(match.group(1), '${ORDER_SYS_ID}', file_string)
match = re.search(r'"name":\s"CASE_ID",\s*"value":\s"([^"]*)"', file_string)
match = re.search(r'"name":\s?"CASE_ID",\s*"value":\s?"([^"]*)"', file_string)
file_string = re.sub(match.group(1), '${CASE_ID}', file_string)
match = re.search(r'"name":\s"ORDER_USER_ID",\s*"value":\s"([^"]*)"', file_string)
match = re.search(r'"name":\s?"ORDER_USER_ID",\s*"value":\s?"([^"]*)"', file_string)
file_string = re.sub(match.group(1), '${ORDER_USER_ID}', file_string)
with open(join(working_dir_json, name_working), "w") as file:
@@ -472,14 +486,14 @@ def get_payload(sheet_name, workbook):
"""
ws = workbook[sheet_name]
i = 3
os.chdir(working_dir)
os.chdir(working_dir_json)
while ws['F' + str(i)].value is not None:
match = re.search(
r'[jJ][sS][oO][nN][\s.]?[Rr][eE][Qq][uUeEsStT.]{0,4}:?\s{0,3}([\S\s]*)[Jj][Ss][Oo][Nn][\s.]?[Rr][Ee][Ss][pPoOnNsSeE.]{0,5}:?',
r'[jJ][sS][oO][nN][\s.]?[Rr][eE][Qq][uUeEsStT.]{0,4}:?\s{0,3}([\S\s]*)[Jj][Ss][Oo][Nn][\s.]{0,3}[Rr][Ee][Ss][pPoOnNsSeE.]{0,5}:?',
ws['F' + str(i)].value)
test_name = ws['C' + str(i)].value
if test_name is None:
print(f'Name missing for line {i}')
print(f'Line {i} Error:{ws["G" + str(i)].value}')
elif match is None:
print(f'Payload missing for line {i}')
else:
@@ -488,7 +502,7 @@ def get_payload(sheet_name, workbook):
i += 1
def get_request_id_cfg_file(sheet_name, workbook, open_mode='w'):
def get_request_id_cfg_file(sheet_name, workbook):
"""
Reads the Dayly report xcel file creates the reqest_ids file for the task generator
and the cfg file for the excel generator
@@ -499,22 +513,23 @@ def get_request_id_cfg_file(sheet_name, workbook, open_mode='w'):
request_ids = []
test_cfg = []
while ws['F' + str(i)].value is not None:
match = re.match('[Rr][Ee][Qq][UuEeSsTt]*.?\s?[Ii][Dd][.:]{0,2}\s{0,4}(\d+)', ws['F' + str(i)].value)
match = re.match('[Rr][Ee][Qq][UuEeSsTt]*.?\s?[Ii][Dd]\s{0,2}[.:]{0,2}\s{0,4}(\d+)', ws['F' + str(i)].value)
test_name = ws['C' + str(i)].value
if test_name is None:
print(f'Name missing for line {i}')
print(f'Line {i} Error:{ws["G" + str(i)].value}')
elif match is None:
print(f'Request missing for line {i}')
else:
request_ids.append(match.group(1))
test_cfg.append(f'{test_name}')
# test_cfg.append(f'{test_name}')
test_cfg.append(f'{match.group(1)}=TC_NAME:{test_name},TC_ID:{test_name}')
i += 1
with open('request_ids.txt', open_mode) as file:
with open('request_ids.txt', "a") as file:
temp_string = ''
for el in request_ids:
temp_string += f'{el}\n'
file.write(temp_string)
with open('cfg_file.txt', open_mode) as file:
with open('cfg_file.txt', "a") as file:
temp_string = ''
for el in test_cfg:
temp_string += f'{el}\n'
@@ -535,68 +550,60 @@ def load_sheet(workbook):
return ws
def operate_cwd(work_on):
"""
Operates over the files in the given working directory comment and uncomment needed functions
returns a list of file names for later sorting
Also returns a list of files later use for numbering them
"""
# JSON
# XLS
for root, dirs, files in os.walk(working_dir_xlsx, topdown=False):
if root != working_dir_xlsx:
continue
for name in files:
if name[-4:] == 'xlsx' and work_on == "xlsx":
pass
workbook = load_workbook(filename=join(root, name))
ws = load_sheet(workbook)
if not ws:
print(f'Failed to load sheet for file {name}')
break
remove_resp_add_first_four_lines(ws)
update_names(ws, name[:-4] + 'json')
remove_sri(ws)
remove_antics(ws)
replace_var_value(ws, name)
workbook.save(filename=join(root, name))
if name[-4:] == 'json' and work_on == 'json':
pass
remove_request_trace(name)
get_service_names(name)
replace_service_names(name)
parametrize_payload(name)
if work_on == 'json':
for root, dirs, files in os.walk(working_dir_json, topdown=False):
if root != working_dir_json:
continue
for name in files:
if name[-4:] == 'json':
replace_var_value(False, name)
# print(f"Successfully modified File:{name}")
def operate_workbook():
def operate_workbook(curret_day, last_day):
"""
Operates the Test Report file, generates cfg file for TAF regression generator,
service names files later used for parametraization and request ids file used to get request from DB
"""
workbook = load_workbook(join(working_dir, 'Test_Report.xlsx'))
curret_day = 3
last_day = 13
with open('request_ids.txt', "w") as file:
pass
with open('cfg_file.txt', "w") as file:
pass
while curret_day < last_day:
get_payload(f'Day {curret_day}', workbook)
print(f'Payload for Day {curret_day} Finished \n --------------------------------------')
get_request_id_cfg_file(f'Day {curret_day}', workbook)
print(f'Request IDS for Day {curret_day} Finished \n --------------------------------------')
check_payload(f'Day {curret_day}', workbook)
curret_day += 1
def check_payload(sheet_name, workbook):
"""
checks if the payload have mismatch between test case name and request and if a sheet has duplicate REQ IDs
"""
ws = workbook[sheet_name]
i = 3
request_ids_temp = []
while ws['F' + str(i)].value is not None:
if ws['C' + str(i)].value is not None:
create_match_payload = re.search(r'Create', ws['F' + str(i)].value)
delete_match_payload = re.search(r'Delete', ws['F' + str(i)].value)
create_match_name = re.search(r'Create', ws['C' + str(i)].value)
delete_match_name = re.search(r'Delete', ws['C' + str(i)].value)
if create_match_name is not None and create_match_payload is None:
print(f"error in sheet{sheet_name} line:{i}")
if delete_match_name is not None and delete_match_payload is None:
print(f"error in sheet{sheet_name} line:{i}")
match = re.match('[Rr][Ee][Qq][UuEeSsTt]*.?\s?[Ii][Dd]\s{0,2}[.:]{0,2}\s{0,4}(\d+)', ws['F' + str(i)].value)
if match is not None:
request_ids_temp.append(match.group(1))
i += 1
seen = set()
dupes = []
for x in request_ids_temp:
if x in seen:
dupes.append(x)
else:
seen.add(x)
if dupes:
print(f'{sheet_name} contains these duplicate request ids:{dupes}')
def init_dir():
"""
Creates the necessary files to operated
Creates the necessary files and dirs to operate
"""
if not os.path.isdir(working_dir_json):
os.mkdir(working_dir_json)
@@ -604,19 +611,42 @@ def init_dir():
os.mkdir(working_dir_sorted)
if not os.path.isdir(working_dir_xlsx):
os.mkdir(working_dir_xlsx)
l = ['LTE', 'M2M', "PostPaid_BUS", "PostPaid_CON", "PostPaid_SP", "PrePaid", "PrePaid_SP"]
l = ['LTE', 'M2M', "PostPaid_BUS", "PostPaid_CON", "PostPaid_SP", "PrePaid", "PrePaid_SP", "IPT"]
for i in l:
if not os.path.isdir(join(working_dir_sorted, i)):
os.mkdir(join(working_dir_sorted, i))
with open(join(working_dir, 'service_names.txt'), 'w') as f:
pass
with open(join(working_dir, 'cfg_file.txt'), 'w') as f:
pass
with open(join(working_dir, 'request_ids.txt'), 'w') as f:
pass
def clear_dir():
"""
Removes the jsons and xlsx's
"""
l = [working_dir_xlsx, working_dir_json, working_dir_sorted]
for top in l:
for root, dirs, files in os.walk(top, topdown=False):
for name in files:
os.remove(os.path.join(root, name))
for name in dirs:
os.rmdir(os.path.join(root, name))
# TEST REPORT OPERATIONS
# init_dir()
# operate_workbook()
# operate_cwd('json')
# operate_cwd('xlsx')
# operate_workbook(13,28)
# operate_cwd_old('json')
operate_cwd_old('xlsx')
# sort_files('xlsx')
# give_number_to_files(2)
# give_number_to_files(54)
# sort_files('json')
# clear_dir()
# remove_number_from_files()