Woffee commited on
Commit
4441b59
·
1 Parent(s): 16c6878

course schedule

Browse files
Files changed (1) hide show
  1. app.py +22 -2
app.py CHANGED
@@ -4,6 +4,9 @@ import pandas as pd
4
  # from groq import Groq
5
  from dotenv import load_dotenv
6
 
 
 
 
7
  os.environ['REQUESTS_CA_BUNDLE'] = '/usr/local/share/zscaler.crt'
8
 
9
 
@@ -16,6 +19,7 @@ def read_excel_and_process(fi):
16
  new_data = {}
17
  row_names = ['8:30-9:50', '10-11:20', '11:30-12:50', '1-2:20', '2:30-3:50', '4-5:20', '6-7:20', '7:30-8:50']
18
  col_names = ['Time', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday/Sunday']
 
19
 
20
  for t in row_names:
21
  new_data[t] = {}
@@ -54,8 +58,24 @@ def read_excel_and_process(fi):
54
  data_2.append(v)
55
 
56
  df = pd.DataFrame.from_dict(data_2)
57
- df.to_excel("visualization.xlsx", index=False)
58
- return "visualization.xlsx"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
 
61
  # def excel_to_csv(fi):
 
4
  # from groq import Groq
5
  from dotenv import load_dotenv
6
 
7
+ from openpyxl import load_workbook
8
+ from openpyxl.styles import Alignment
9
+
10
  os.environ['REQUESTS_CA_BUNDLE'] = '/usr/local/share/zscaler.crt'
11
 
12
 
 
19
  new_data = {}
20
  row_names = ['8:30-9:50', '10-11:20', '11:30-12:50', '1-2:20', '2:30-3:50', '4-5:20', '6-7:20', '7:30-8:50']
21
  col_names = ['Time', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday/Sunday']
22
+ column_widths = [15, 40, 40, 40, 40, 40, 40]
23
 
24
  for t in row_names:
25
  new_data[t] = {}
 
58
  data_2.append(v)
59
 
60
  df = pd.DataFrame.from_dict(data_2)
61
+ # df.to_excel("visualization.xlsx", index=False)
62
+ # return "visualization.xlsx"
63
+
64
+
65
+ with pd.ExcelWriter('visualization.xlsx', engine='openpyxl') as writer:
66
+ df.to_excel(writer, sheet_name='Sheet1', index=False)
67
+
68
+ workbook = writer.book
69
+ worksheet = writer.sheets['Sheet1']
70
+
71
+ for i, width in enumerate(column_widths):
72
+ column_letter = chr(65 + i) # change index col to(A, B, C,...)
73
+ worksheet.column_dimensions[column_letter].width = width
74
+
75
+ for cell in worksheet[column_letter]:
76
+ cell.alignment = Alignment(wrap_text=True)
77
+
78
+
79
 
80
 
81
  # def excel_to_csv(fi):