def reset_max_row_json(): folder_path = get_folder_path() max_row_json = open(str(folder_path.joinpath(MAX_ROW_FILE))) max_row_dettaglio_prezzo = load(max_row_json) max_row_json.close() for year in max_row_dettaglio_prezzo.keys(): for house in max_row_dettaglio_prezzo[year]: max_row_dettaglio_prezzo[year][house] = 2 max_row_json = open(str(folder_path.joinpath(MAX_ROW_FILE)), mode='w') dump(max_row_dettaglio_prezzo, max_row_json, indent=4) max_row_json.close()
def generate_json(ws_file, column_file): folder_path = get_folder_path() file_path = PurePath.joinpath(folder_path, ws_file) column_path = PurePath.joinpath(folder_path, column_file) wb = load_workbook(file_path, data_only=True) ws_riepilogo = wb[RIEPILOGO_WS] column_label = {} column_apartment_file = open(file=str(column_path), mode='w') for current_column in range(1, 91): current_cell = ws_riepilogo.cell(row=1, column=current_column) if current_cell.value is not None: column_label[current_cell.value] = current_column current_column += 1 dump(column_label, column_apartment_file, indent=4, ensure_ascii=False) print('JSON generato')
from datetime import datetime from json import load from pathlib import PurePath from prenotazioni.constants import MASTER_FILE, COLUMN_FILE, APARTMENT_FILE, RIEPILOGO_WS, RENDICONTO_WS from prenotazioni.utils.excel_utils import find_max_row, get_info_reservation, open_workbook, open_worksheet from prenotazioni.style_worksheet.style_excel import erase_future_reservation, set_rendiconto_occupation_cell,\ set_rendiconto_gross_cell, set_rendiconto_net_cell, set_cell_reservation_break from prenotazioni.utils.json_utils import find_column_apartment from prenotazioni.utils.path_utils import get_folder_path from prenotazioni.utils.path_utils import create_copy # set path of the folder folder_path = get_folder_path() # set the name of excel file name_file = MASTER_FILE # set the path of excel file wb_master_path = folder_path.joinpath(name_file) # open all resources files json_column_file = open(str(PurePath.joinpath(folder_path, COLUMN_FILE))) json_apartment_file = open(str(PurePath.joinpath(folder_path, APARTMENT_FILE))) apartment_json = load(json_apartment_file) column_label = load(json_column_file) print(f'Apertura file excel in corso...\n') # open all excel workbook wb, file_path = open_workbook(wb_master_path, data_only=False)