I have a excel data like as below
USA EVENT 2021,
USA - OVERALL REVENUE - DIVISION,FY_1920,FY_2021,FY_2122
CARS,
VEHICLES,
LORRIES,
2-WHEELERS
I would like to replace certain keywords in above excel data. So, I used python xlwings package to replace keywords in excel sheet.
For ex: EVENT 2021 has to be replaced by EVENT 2022. Similarly, user will have to replace a list of keywords. But the problem is how can I dynamically generate the number of code lines to execute?
For ex: If user enters wants only EVENT 2021 to be replaced with EVENT 2022, only below line should be code.
sheet1.used_range.api.Replace("EVENT 2021", "EVENT 2022")
For ex: If user enters wants two words - EVENT 2021, FY_2122 to be replaced with EVENT 2022 and FY_2223 below two line should be executed.
sheet1.used_range.api.Replace("EVENT 2021", "EVENT 2022")
sheet1.used_range.api.Replace("FY_2122", "FY_2223")
For ex: If user enters wants three words - EVENT 2021, FY_2122, FY_2021 to be replaced with EVENT 2022,FY_2223 and FY_2122, below three lines should be executed.
sheet1.used_range.api.Replace("EVENT 2021", "EVENT 2022")
sheet1.used_range.api.Replace("FY_2122", "FY_2223")
sheet1.used_range.api.Replace("FY_2021", "FY_2122")
As you can see, the code lines is same and repeating based on number of keywords to replace.
How can I get an input from user in runtime (for tkinter like GUI) and let pandas decide how many lines of code to run?
How to make this dynamic? Instead of me, manually writing n lines of code for n keywords
