-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataDistribution.py
60 lines (55 loc) · 1.85 KB
/
DataDistribution.py
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
__author__ = 'elizajasin'
import os
import openpyxl
from openpyxl import Workbook
os.getcwd
wb = openpyxl.load_workbook('hadits_v4.xlsx')
ws = wb.active
informasi = []
anjuran = []
larangan = []
for i in range (2,ws.max_row+1):
if ws.cell(row=i,column=ws.max_column).value == 1:
informasi.append(str(ws.cell(row=i,column=ws.max_column-1).value))
elif ws.cell(row=i,column=ws.max_column).value == 2:
anjuran.append(str(ws.cell(row=i,column=ws.max_column-1).value))
else:
larangan.append(str(ws.cell(row=i,column=ws.max_column-1).value))
# wb = openpyxl.load_workbook('hadits_fix_7008_balance.xlsx')
# ws = wb.active
# for i in range (2,ws.max_row+1):
# if ws.cell(row=i,column=ws.max_column).value == 1:
# informasi.append(str(ws.cell(row=i,column=ws.max_column-1).value))
# elif ws.cell(row=i,column=ws.max_column).value == 2:
# anjuran.append(str(ws.cell(row=i,column=ws.max_column-1).value))
# else:
# larangan.append(str(ws.cell(row=i,column=ws.max_column-1).value))
#
# wb = openpyxl.load_workbook('hadits_fix_3.xlsx')
# ws = wb.active
# for i in range (2,ws.max_row+1):
# if ws.cell(row=i,column=ws.max_column).value == 1:
# informasi.append(str(ws.cell(row=i,column=ws.max_column-1).value))
# elif ws.cell(row=i,column=ws.max_column).value == 2:
# anjuran.append(str(ws.cell(row=i,column=ws.max_column-1).value))
# else:
# larangan.append(str(ws.cell(row=i,column=ws.max_column-1).value))
wb = Workbook()
ws = wb.active
for i in range(550):
data = []
data.append(informasi[i])
data.append(1)
ws.append(data)
data = []
data.append(anjuran[i])
data.append(2)
ws.append(data)
data = []
data.append(larangan[i])
data.append(3)
ws.append(data)
wb.save('hadits_v4_fix.xlsx')
print(len(informasi))
print(len(anjuran))
print(len(larangan))