From 8fa154a8a2f1d390f628d230c1e7963cdbbbbdce Mon Sep 17 00:00:00 2001 From: hsafaei Date: Sun, 1 Jun 2025 17:12:50 +0330 Subject: [PATCH] 1 --- r3_import_excel_tcodes.py | 34 +++++++++++---------- r5_import_codes.py => r5_import_50_codes.py | 0 temp_codes.py | 22 ++++++++----- 3 files changed, 33 insertions(+), 23 deletions(-) rename r5_import_codes.py => r5_import_50_codes.py (100%) diff --git a/r3_import_excel_tcodes.py b/r3_import_excel_tcodes.py index 65e7bfa..008bfbd 100644 --- a/r3_import_excel_tcodes.py +++ b/r3_import_excel_tcodes.py @@ -215,10 +215,11 @@ def importDataToElastic(elastic, file_excel, index_name_o, tcode_label, tcode_id qanon_title = row[column_names[2]] code_state = row[column_names[3]] row_number = row[column_names[4]] - if code_state : - print ( 'ddddddddddddddcode_state' , code_state) - else : - print ( 'ccccccccccccccode_state' , code_state) + # if code_state : + # print ( 'ddddddddddddddcode_state' , code_state) + # else : + # print ( 'ccccccccccccccode_state' , code_state) + qanon_id = 0 section_id = 0 state = '' @@ -296,10 +297,11 @@ def importDataToElastic(elastic, file_excel, index_name_o, tcode_label, tcode_id "label" : tcode_label, "id" : tcode_id } - if code_state : + if code_state == True : tcode_mains.append(code) else: - tcode_subs.append(code) + tcode_subs.append(code) + data={ '_id':section_id, '_source' : { @@ -325,18 +327,18 @@ def importDataToElastic(elastic, file_excel, index_name_o, tcode_label, tcode_id elastic.updateBulkList(bulk_data, index_name_o) - # columns=['جزء', 'مصوب', 'قانون', 'اصلی', 'ردیف', 'شناسه قانون', 'شناسه جزء', 'وضعیت پردازش'] - columns=[0, 1, 2, 3, 4, 5, 6, 7] - new_df = pd.DataFrame(rows_list_new, columns=columns) - if result_path == '' : - directory_path = os.path.dirname(file_excel) - result_path = directory_path + "/result/" + ##### columns=['جزء', 'مصوب', 'قانون', 'اصلی', 'ردیف', 'شناسه قانون', 'شناسه جزء', 'وضعیت پردازش'] + # columns=[0, 1, 2, 3, 4, 5, 6, 7] + # new_df = pd.DataFrame(rows_list_new, columns=columns) + # if result_path == '' : + # directory_path = os.path.dirname(file_excel) + # result_path = directory_path + "/result/" - file_name = os.path.basename(file_excel) - file_excel2 = result_path + file_name.replace('.xlsx', '_result.xlsx') + # file_name = os.path.basename(file_excel) + # file_excel2 = result_path + file_name.replace('.xlsx', '_result.xlsx') - print('rows_list_new', str(len(rows_list_new)), ' --> ', file_excel2) - new_df.to_excel(file_excel2, index=False, engine='openpyxl') + # print('rows_list_new', str(len(rows_list_new)), ' --> ', file_excel2) + # new_df.to_excel(file_excel2, index=False, engine='openpyxl') except Exception as e: diff --git a/r5_import_codes.py b/r5_import_50_codes.py similarity index 100% rename from r5_import_codes.py rename to r5_import_50_codes.py diff --git a/temp_codes.py b/temp_codes.py index 45328c3..63534a4 100644 --- a/temp_codes.py +++ b/temp_codes.py @@ -16,8 +16,8 @@ from temp_LawSection_content import * load_dotenv(dotenv_path='config.env') -# host=os.getenv('HOST_160') -# password=os.getenv('HOST_160_PASS') +host=os.getenv('HOST_160') +password=os.getenv('HOST_160_PASS') @@ -30,8 +30,8 @@ load_dotenv(dotenv_path='config.env') # host=os.getenv('HOST_161') # password=os.getenv('HOST_161_PASS') -host=os.getenv('HOST_80') -password=os.getenv('HOST_80_PASS') +# host=os.getenv('HOST_80') +# password=os.getenv('HOST_80_PASS') print(host) @@ -40,9 +40,17 @@ print(host) path_base_map = "G:/Project2/gateway2_main/repo/_other/" elastic = ElasticHelper(host, password, "elastic", path_base_map) +# elastic.backupIndexToZipfile("G:/Project2/111/haditha", "dh_volume") +# elastic.backupIndexToZipfile("G:/Project2/111/haditha", "dh_haditha") + +# elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section-m1") +# elastic.createIndex( 'mj_qa_section-m1', 'majles', 'mj_qa_section') + +# elastic.restorFileToElastic2('G:/Project2/111/mj_qa_section-m1.zip', 'mj_qa_section-m1', 'majles', False, 'mj_qa_section') + #elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section") - +# elastic.restorFileToElastic2('G:/Project2/111/gn_setting.zip', 'gn_setting', 'general', False, 'gn_setting') #------------------------------------------------------- ## # elastic.backupIndexToZipfile("G:/Project2/111", "dh_haditha") @@ -80,7 +88,7 @@ elastic = ElasticHelper(host, password, "elastic", path_base_map) #------------------------------------------------------- ## backup from 160 #------------------------------------------------------- -# path_back = 'G:/Project2/_back/server160/_back_elastic0126/' +path_back = 'G:/Project2/111/server160/' # elastic.backupIndexToZipfile(path_back, "gn_log_change") # elastic.backupIndexToZipfile(path_back, "gn_log_action") # elastic.backupIndexToZipfile(path_back, "gn_log_search") @@ -89,7 +97,7 @@ elastic = ElasticHelper(host, password, "elastic", path_base_map) # elastic.backupIndexToZipfile(path_back, "gn_bayanat") # elastic.backupIndexToZipfile(path_back, "gn_entity") # elastic.backupIndexToZipfile(path_back, "gn_research") -# elastic.backupIndexToZipfile(path_back, "gn_dataset") +# elastic.backupIndexToZipfile(path_back, "gn_dataset") # elastic.backupIndexToZipfile(path_back, "mj_mashruh")