Guest User

Untitled

a guest
Jan 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. import sys
  2. import tkinter
  3. from tkinter import filedialog
  4. from openpyxl import load_workbook
  5.  
  6.  
  7. def thecloser(n):
  8. if n == "exit":
  9. sys.exit(0)
  10. else:
  11. print("Type exit to close this window!")
  12. thecloser(input())
  13.  
  14.  
  15. def main():
  16. root = tkinter.Tk()
  17. root.withdraw()
  18.  
  19. print("Are you ready? press any key! -- :::::Program By Jerson Abraham:::::")
  20.  
  21. input()
  22.  
  23. Afile = filedialog.askopenfilename(initialdir="/", title="Select file",
  24. filetypes=(("xlsx files", "*.xlsx"), ("all files", "*.*")))
  25.  
  26. Cfile = filedialog.askopenfilename(initialdir="/", title="Select file",
  27. filetypes=(("xlsx files", "*.xlsx"), ("all files", "*.*")))
  28.  
  29. Bfile = filedialog.askopenfilename(initialdir="/", title="Select file",
  30. filetypes=(("xlsx files", "*.xlsx"), ("all files", "*.*")))
  31.  
  32. print("Loading Excel Files... This may take some time!")
  33.  
  34. Afilebook = load_workbook(Afile)
  35. Afile = Afilebook.active
  36.  
  37. Cfile = load_workbook(Cfile)
  38. Cfile = Cfile.active
  39.  
  40. Bfile = load_workbook(Bfile)
  41. Bfile = Bfile.active
  42.  
  43. print("Loading Done!! Processing your work!!")
  44.  
  45. for Afilecell in Afile['C']:
  46. if Afilecell.value is not None:
  47.  
  48. for Bfilecell in Bfile['H']:
  49. if Bfilecell.value is not None:
  50. if Afilecell.value in Bfilecell.value:
  51. Afile.cell(row=Afilecell.row, column=27).value = Bfile.cell(row=Bfilecell.row, column=50).value
  52. Afile.cell(row=Afilecell.row, column=28).value = Bfile.cell(row=Bfilecell.row, column=51).value
  53. Afile.cell(row=Afilecell.row, column=29).value = Bfile.cell(row=Bfilecell.row, column=52).value
  54. Afile.cell(row=Afilecell.row, column=30).value = Bfile.cell(row=Bfilecell.row, column=53).value
  55. Afile.cell(row=Afilecell.row, column=31).value = Bfile.cell(row=Bfilecell.row, column=54).value
  56. Afile.cell(row=Afilecell.row, column=32).value = Bfile.cell(row=Bfilecell.row, column=55).value
  57. Afile.cell(row=Afilecell.row, column=33).value = Bfile.cell(row=Bfilecell.row, column=56).value
  58. Afile.cell(row=Afilecell.row, column=34).value = Bfile.cell(row=Bfilecell.row, column=57).value
  59. Afile.cell(row=Afilecell.row, column=35).value = Bfile.cell(row=Bfilecell.row, column=58).value
  60.  
  61. for Cfilecell in Cfile['B']:
  62. if Cfilecell.value is not None:
  63. if Afilecell.value in Cfilecell.value:
  64. Afile.cell(row=Afilecell.row, column=20).value = Cfile.cell(row=Cfilecell.row, column=40).value
  65. Afile.cell(row=Afilecell.row, column=21).value = Cfile.cell(row=Cfilecell.row, column=41).value
  66. Afile.cell(row=Afilecell.row, column=22).value = Cfile.cell(row=Cfilecell.row, column=42).value
  67. Afile.cell(row=Afilecell.row, column=23).value = Cfile.cell(row=Cfilecell.row, column=43).value
  68. Afile.cell(row=Afilecell.row, column=24).value = Cfile.cell(row=Cfilecell.row, column=44).value
  69. Afile.cell(row=Afilecell.row, column=25).value = Cfile.cell(row=Cfilecell.row, column=45).value
  70. Afile.cell(row=Afilecell.row, column=26).value = Cfile.cell(row=Cfilecell.row, column=46).value
  71.  
  72. print("Processing Done! File will Saved as output.xlsx")
  73.  
  74. Afilebook.save('output.xlsx')
  75.  
  76. print("All Done! Type exit to close this window!")
  77. thecloser(input())
  78.  
  79.  
  80. try:
  81. main()
  82. except Exception as e:
  83. print(e)
  84.  
  85. print("Type exit to close this window!")
  86. thecloser(input())
Add Comment
Please, Sign In to add comment