-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFlowchart5.py
More file actions
40 lines (28 loc) · 936 Bytes
/
Flowchart5.py
File metadata and controls
40 lines (28 loc) · 936 Bytes
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
import xlrd
import pydot
graph = pydot.Dot(graph_type='digraph')
graph.set_strict(1)
ExcelFileName = 'example.xlsx'
workbook = xlrd.open_workbook(ExcelFileName)
worksheet = workbook.sheet_by_name("Sheet1")
num_rows = worksheet.nrows
num_cols = worksheet.ncols
result_data = []
for curr_row in range(0, num_rows, 1):
row_data = []
for curr_col in range(0, num_cols, 1):
data = worksheet.cell_value(curr_row, curr_col) # Read the data in the current cell
# print(data)
row_data.append(data)
result_data.append(row_data)
node = result_data[1]
for i in range(len(result_data[1])):
node[i] = pydot.Node(result_data[1][i], style="rounded, filled", shape="box")
graph.add_node(node[i])
j = 0
k = 1
for i in range(len(set(node))-1):
graph.add_edge(pydot.Edge(node[j], node[k], dir="forward", arrowhead="normal", style=""))
j += 1
k += 1
graph.write_png('example3_graph.png')