Skip to content

Commit fcf5577

Browse files
committed
Enhancement
1 parent 8aedce0 commit fcf5577

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed
225 Bytes
Binary file not shown.

bunker_mod.py

+20-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# import plotly.graph_objects as go
99
# from plotly.subplots import make_subplots
1010
import pandas as pd
11+
import numpy as np
1112

1213

1314
# def many_pieplot(res,specs,subplot_titles,labels,total_class,total_present):
@@ -249,7 +250,7 @@ def return_cgpa(session):
249250
for index,row in enumerate(rows):
250251

251252
cols = row.find_all('td')
252-
cols = [ele.text.strip() for ele in cols]
253+
cols = [ele.text for ele in cols]
253254
latest_sem_data.append([ele for ele in cols if ele])
254255
except:
255256
print("No results available !!")
@@ -271,21 +272,31 @@ def return_cgpa(session):
271272
cols = [ele.text.strip() for ele in cols]
272273
data.append([ele for ele in cols if ele])
273274
except:
274-
return {"error" : "no data"}
275+
print("No Course Info available !!")
275276
else:
276-
return {"error" : "no data"}
277+
print("No Course Info available !!")
277278

278-
cols = data.pop(0)
279-
df = pd.DataFrame(data, columns=cols)
280-
281-
# Add latest sem results if available
279+
global df
280+
global latest_sem_records
281+
282+
# Preprocess latest sem results if available
282283
if len(latest_sem_data) != 0:
283284
latest_sem_data.pop(0)
284285
latest_sem_records = pd.DataFrame(latest_sem_data, columns=['COURSE SEM', 'COURSE CODE', 'COURSE TITLE', 'CREDITS', 'GRADE', 'RESULT'])
285286
latest_sem_records['GRADE'] = latest_sem_records['GRADE'].str.split().str[-1]
287+
latest_sem_records['COURSE SEM'] = latest_sem_records['COURSE SEM'].replace(r'^\s*$', np.nan, regex=True)
288+
latest_sem_records['COURSE SEM'].fillna(method='ffill', inplace=True)
286289

287-
df = df.append(latest_sem_records, ignore_index=True)
288-
df.drop_duplicates(subset="COURSE CODE", keep="last", inplace=True)
290+
try:
291+
cols = data.pop(0)
292+
df = pd.DataFrame(data, columns=cols)
293+
294+
# Add latest sem results if available
295+
if len(latest_sem_data) != 0:
296+
df = df.append(latest_sem_records, ignore_index=True)
297+
df.drop_duplicates(subset="COURSE CODE", keep="last", inplace=True)
298+
except:
299+
df = latest_sem_records.copy()
289300

290301
# CPGA calculation
291302
latest_sem = df['COURSE SEM'].max()

0 commit comments

Comments
 (0)