|
|
|
import requests |
|
import pandas as pd |
|
from io import BytesIO |
|
from bs4 import BeautifulSoup |
|
from IPython.display import HTML, display |
|
from IPython.display import clear_output |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def display_application_decision(): |
|
"""Displays the application decision in an HTML table based on user input.""" |
|
|
|
while True: |
|
application_number_input = input("Enter your Application Number (including IRL if applicable): ") |
|
if "irl" in application_number_input.lower(): |
|
try: |
|
application_number = int("".join(filter(str.isdigit, application_number_input.lower().split("irl")[-1]))) |
|
if len(str(application_number)) < 8: |
|
print("Please enter a valid application number with minimum 8 digits after IRL.") |
|
continue |
|
break |
|
except ValueError: |
|
print("Invalid input after IRL. Please enter only digits.") |
|
continue |
|
|
|
else: |
|
if not application_number_input.isdigit(): |
|
print("Invalid input. Please enter only digits.") |
|
continue |
|
elif len(application_number_input) < 8: |
|
print("Please enter at least 8 digits for your VISA application number.") |
|
continue |
|
else: |
|
application_number = int(application_number_input) |
|
break |
|
|
|
|
|
row = df[df['Application Number'] == application_number] |
|
|
|
if not row.empty: |
|
|
|
if row['Decision'].iloc[0] == 'Approved': |
|
print("Congratulations! Your Visa application has been approved.") |
|
|
|
|
|
html_table = """ |
|
<html> |
|
<body> |
|
<table border="1" style="border-collapse: collapse;"> |
|
<tr> |
|
<th style="border: 1px solid black;">Application Number</th> |
|
<th style="border: 1px solid black;">Decision</th> |
|
</tr> |
|
<tr> |
|
<td style="border: 1px solid black;">{}</td> |
|
<td style="border: 1px solid black;">{}</td> |
|
</tr> |
|
</table> |
|
</body> |
|
</html> |
|
""".format(row['Application Number'].iloc[0], row['Decision'].iloc[0]) |
|
|
|
|
|
clear_output(wait=True) |
|
display(HTML(html_table)) |
|
else: |
|
print("Application number", application_number, "not found in the data.") |
|
|
|
|
|
df['Difference'] = abs(df['Application Number'] - application_number) |
|
nearest_records = df.nsmallest(2, 'Difference') |
|
|
|
if not nearest_records.empty: |
|
|
|
html_table = """ |
|
<html> |
|
<body> |
|
<h3>Application number not found. Showing nearest records:</h3> |
|
<table border="1" style="border-collapse: collapse;"> |
|
<tr> |
|
<th style="border: 1px solid black;">Application Number</th> |
|
<th style="border: 1px solid black;">Decision</th> |
|
<th style="border: 1px solid black;">Difference</th> |
|
</tr> |
|
""" |
|
for _, row in nearest_records.iterrows(): |
|
html_table += """ |
|
<tr> |
|
<td style="border: 1px solid black;">{}</td> |
|
<td style="border: 1px solid black;">{}</td> |
|
<td style="border: 1px solid black;">{}</td> |
|
</tr> |
|
""".format(row['Application Number'], row['Decision'], row['Difference']) |
|
|
|
html_table += """ |
|
</table> |
|
</body> |
|
</html> |
|
""" |
|
|
|
clear_output(wait=True) |
|
display(HTML(html_table)) |
|
else: |
|
print("Application number not found, and no nearest records found in the data.") |
|
|
|
|
|
|
|
display_application_decision() |