Guest User

Untitled

a guest
Nov 16th, 2023
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. TEMPLATES = {
  2. "TAURON Dystrybucja S.A Katowice": {
  3. "needed_cells": ["B2", "B3", "B4"]
  4. },
  5. "Orange Polska S.A. Kraków": {
  6. "needed_cells": ["B2"]
  7. }
  8. }
  9.  
  10. while True:
  11. try:
  12. wb = openpyxl.load_workbook(modified_xlsx_path)
  13. sheet = wb["input"]
  14. title = sheet["B2"].value
  15. gas_grid_or_connection_uppercase = sheet["B3"].value.upper()
  16. road_plots = sheet["B4"].value
  17. county = sheet["B5"].value.upper()
  18. gas_grid = sheet["B6"].value
  19. gas_connection = sheet["B7"].value
  20. postal_code = sheet["B8"].value
  21. gas_grid_or_connection_lowercase = sheet["B3"].value.lower()
  22. sheet = wb["additional_data"]
  23. sheet["A2"] = get_attr_from_title(title)[1]
  24. sheet["A3"] = get_attr_from_title(title)[3]
  25. sheet["A4"] = get_attr_from_title(title)[0]
  26. sheet["A5"] = get_attr_from_title(title)[2]
  27. sheet["A6"] = get_attr_from_title(title)[4]
  28. sheet["A7"] = get_attr_from_title(title)[5]
  29. city = sheet["A2"].value.upper()
  30. street = sheet["A3"].value.upper()
  31. plots = sheet["A4"].value
  32. municipality = sheet["A5"].value.upper()
  33. stripped_title = sheet["A6"].value.upper()
  34. city_street_plots = sheet["A7"].value.upper()
  35. wb.save(modified_xlsx_path)
  36. # Read data from the workbook
  37. # Perform any necessary operations
  38. break # If the file was opened successfully, break out of the loop
  39. except PermissionError:
  40. print(f"PermissionError: Plik {modified_xlsx_path} jest otwarty. Proszę zamknij plik i spróbuj jeszcze raz ")
  41. get_yes_no_input(f"Czy zamknąłeś plik {modified_xlsx_path}? ")
  42.  
  43. TEMPLATES = {
  44. "Orange Polska S.A. Kraków": {
  45. "replacements": {
  46. "gas_grid_or_connection_uppercase": gas_grid_or_connection_uppercase,
  47. "title": stripped_title,
  48. "road_plots": road_plots,
  49. "city": city,
  50. "street": street,
  51. "gas_grid_or_connection_lowercase": gas_grid_or_connection_lowercase
  52. }
  53. },
  54. "TAURON Dystrybucja S.A Katowice":{
  55. "replacements": {
  56. "gas_grid_or_connection_uppercase": gas_grid_or_connection_uppercase,
  57. "title": stripped_title,
  58. "road_plots": road_plots,
  59. "city": city,
  60. "street": street,
  61. "gas_grid_or_connection_lowercase": gas_grid_or_connection_lowercase
  62. }
  63. },
  64. }
Advertisement
Add Comment
Please, Sign In to add comment