Created
November 9, 2022 04:43
-
-
Save mr-internetix/480751542021428a8e6352961d946f86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import openpyxl | |
import random | |
data = pd.read_excel('Book1.xlsx', usecols="C,D,E,F") | |
wb = openpyxl.load_workbook('Book1.xlsx') | |
sheet = wb.active | |
columns = ["C", "D", "E", "F"] | |
try: | |
#range can be set manually | |
for i in range(0, 6000): | |
options = [sheet[f"C{i+1}"].value, sheet[f"D{i+1}"].value, | |
sheet[f"E{i+1}"].value, sheet[f"F{i+1}"].value] | |
random.shuffle(options) | |
print(options) | |
sheet[f"C{i+1}"].value = options[0] | |
sheet[f"D{i+1}"].value = options[1] | |
sheet[f"E{i+1}"].value = options[2] | |
sheet[f"F{i+1}"].value = options[3] | |
wb.save('output.xlsx') | |
except Exception as e: | |
print(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment