Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TEMPLATES = {
- "TAURON Dystrybucja S.A Katowice": {
- "needed_cells": ["B2", "B3", "B4"]
- },
- "Orange Polska S.A. Kraków": {
- "needed_cells": ["B2"]
- }
- }
- while True:
- try:
- wb = openpyxl.load_workbook(modified_xlsx_path)
- sheet = wb["input"]
- title = sheet["B2"].value
- gas_grid_or_connection_uppercase = sheet["B3"].value.upper()
- road_plots = sheet["B4"].value
- county = sheet["B5"].value.upper()
- gas_grid = sheet["B6"].value
- gas_connection = sheet["B7"].value
- postal_code = sheet["B8"].value
- gas_grid_or_connection_lowercase = sheet["B3"].value.lower()
- sheet = wb["additional_data"]
- sheet["A2"] = get_attr_from_title(title)[1]
- sheet["A3"] = get_attr_from_title(title)[3]
- sheet["A4"] = get_attr_from_title(title)[0]
- sheet["A5"] = get_attr_from_title(title)[2]
- sheet["A6"] = get_attr_from_title(title)[4]
- sheet["A7"] = get_attr_from_title(title)[5]
- city = sheet["A2"].value.upper()
- street = sheet["A3"].value.upper()
- plots = sheet["A4"].value
- municipality = sheet["A5"].value.upper()
- stripped_title = sheet["A6"].value.upper()
- city_street_plots = sheet["A7"].value.upper()
- wb.save(modified_xlsx_path)
- # Read data from the workbook
- # Perform any necessary operations
- break # If the file was opened successfully, break out of the loop
- except PermissionError:
- print(f"PermissionError: Plik {modified_xlsx_path} jest otwarty. Proszę zamknij plik i spróbuj jeszcze raz ")
- get_yes_no_input(f"Czy zamknąłeś plik {modified_xlsx_path}? ")
- TEMPLATES = {
- "Orange Polska S.A. Kraków": {
- "replacements": {
- "gas_grid_or_connection_uppercase": gas_grid_or_connection_uppercase,
- "title": stripped_title,
- "road_plots": road_plots,
- "city": city,
- "street": street,
- "gas_grid_or_connection_lowercase": gas_grid_or_connection_lowercase
- }
- },
- "TAURON Dystrybucja S.A Katowice":{
- "replacements": {
- "gas_grid_or_connection_uppercase": gas_grid_or_connection_uppercase,
- "title": stripped_title,
- "road_plots": road_plots,
- "city": city,
- "street": street,
- "gas_grid_or_connection_lowercase": gas_grid_or_connection_lowercase
- }
- },
- }
Advertisement
Add Comment
Please, Sign In to add comment