-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseparateGames.py
More file actions
78 lines (68 loc) · 1.96 KB
/
Copy pathseparateGames.py
File metadata and controls
78 lines (68 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#read from sheet, copy to other sheets in categories
import openpyxl
import sys
file = "SteamGames.xlsx"
wb = openpyxl.load_workbook(file)
def readSheet():
games = []
ws = wb["Sheet"]
for row in ws.iter_rows():
for cell in row:
games.append(cell.value)
return games
def getSheet():
try:
x = input("\nSelect sheet:\n"
"1. Play Soon\n"
"2. Play Someday\n"
"3. Play Never\n"
"4. Finished\n"
"5. Dropped or Unfinished\n\n")
except:
print("Please close the file before making changes.")
sys.exit()
if x == "1":
return "Soon"
elif x == "2":
return "Someday"
elif x == "3":
return "Never"
elif x == "4":
return "Finished"
elif x == "5":
return "Unfinished"
elif x.upper() == "QUIT":
wb.save(file)
print("File saved.")
return None
else:
return "Other"
def exportToExcel(gameList):
if len(wb.sheetnames) == 1: #prevents sheets being made multiple times on subsequent runs
ws1 = wb.create_sheet("Soon")
ws2 = wb.create_sheet("Someday")
ws3 = wb.create_sheet("Never")
ws4 = wb.create_sheet("Finished")
ws5 = wb.create_sheet("Unfinished")
ws6 = wb.create_sheet("Other")
gameSheet = wb.active
x = input("Start from?\n")
x = int(x)
for i in range(x,len(gameList)):
print(gameList[i])
sheet = getSheet()
if sheet == None:
print("Games finished:", i)
sys.exit()
gameSheet = wb[sheet]
gameSheet.cell(row=i+1, column=1, value=gameList[i])
wb.save(file)
class separateGames():
def main():
print("Enter 'quit' to save and quit.")
games = readSheet()
for i in range(0,len(games)):
exportToExcel(games)
return 0
if __name__ == "__main__":
main()