Spaces:
Sleeping
Sleeping
Update app.py
Browse files41 unmodified lines4243444546471 unmodified line49505152535455562 unmodified lines59606162636465666741 unmodified linesclient = gspread.authorize(creds)return client# ===== Save to Google Sheets =====# ===== Save to Google Sheets =====def save_to_gsheet(name, student_id, major, prediction, sheet_name="Trang tính1"):1 unmodified linenow = datetime.now()current_time = now.strftime("%Y-%m-%d %H:%M:%S")# Create a data row to insert into the sheetdata_row = [name, student_id, major, prediction, current_time]# Connect to Google Sheetsclient = get_gsheet_client()2 unmodified linessheet_id = "1i7bDNvLVLXN93_e-FN0JLzpg1jb64Z_aEuyPjIfwbdQ" # Use your actual ID heresheet = client.open_by_key(sheet_id).worksheet(sheet_name)# Append data to the sheetsheet.append_row(data_row)# ===== List all sheet names =====# def list_sheet_names(sheet_id):# client = get_gsheet_client()41 unmodified lines424344454647481 unmodified line50515253545556575859606162636465666768692 unmodified lines727374757677787980818283848541 unmodified linesclient = gspread.authorize(creds)return client# ===== Save to Google Sheets =====# ===== Save to Google Sheets =====# ===== Save to Google Sheets =====def save_to_gsheet(name, student_id, major, prediction, sheet_name="Trang tính1"):1 unmodified linenow = datetime.now()current_time = now.strftime("%Y-%m-%d %H:%M:%S")# Convert prediction to the proper result in Vietnameseif isinstance(prediction, np.ndarray):prediction = prediction.tolist() # Convert ndarray to listelse:prediction = str(prediction) # Ensure it's a string if it's not a list# Convert prediction to "Đúng hạn" or "Không đúng hạn"if prediction == 1:prediction_result = "Đúng hạn"else:prediction_result = "Không đúng hạn"# Create a data row to insert into the sheetdata_row = [name, student_id, major, prediction_result, current_time]# Connect to Google Sheetsclient = get_gsheet_client()2 unmodified linessheet_id = "1i7bDNvLVLXN93_e-FN0JLzpg1jb64Z_aEuyPjIfwbdQ" # Use your actual ID heresheet = client.open_by_key(sheet_id).worksheet(sheet_name)# Check if columns are set, if not, add them as headersif not sheet.get_all_values(): # If the sheet is emptysheet.append_row(["STT", "Họ và tên", "MSV", "Khoa", "Dự báo", "Thời gian"]) # Create headers# Append data to the sheetsheet.append_row(data_row)# ===== List all sheet names =====# def list_sheet_names(sheet_id):# client = get_gsheet_client()
app.py+19-1