Delhi_Irish_visa_decisions / copy_of_visa_decision.py
SR05's picture
Upload copy_of_visa_decision.py
20dc1ee verified
# -*- coding: utf-8 -*-
"""Copy of Visa_decision.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1adoBwMAeDiJsePxTmnMcatkjYw3RyJpm
"""
#%pip install requests beautifulsoup4
#%pip install pandas odfpy
#%pip install pandas odfpy requests
import requests
import pandas as pd
from io import BytesIO
from bs4 import BeautifulSoup
# ... (Your existing code for fetching and processing the data remains the same) ...
# ... (Code for reading .ods file, cleaning data, and creating the df DataFrame) ...
def display_application_decision():
"""Displays the application decision in an HTML table based on user input."""
application_number = input("Enter your Application Number: ")
try:
application_number = int(application_number)
except ValueError:
print("Invalid input. Please enter a valid application number.")
return
# Find the row corresponding to the entered application number.
row = df[df['Application Number'] == application_number]
if not row.empty:
# Create HTML table string
html_table = """
<html>
<body>
<table>
<tr>
<th>Application Number</th>
<th>Decision</th>
</tr>
<tr>
<td>{}</td>
<td>{}</td>
</tr>
</table>
</body>
</html>
""".format(row['Application Number'].iloc[0], row['Decision'].iloc[0])
# Display the HTML table
from IPython.display import HTML
display(HTML(html_table))
else:
print("Application number not found in the data.")
# Call the function to start the process
display_application_decision()
import requests
import pandas as pd
from io import BytesIO
from bs4 import BeautifulSoup
from IPython.display import HTML
# ... (Your existing code for fetching and processing the data remains the same) ...
# ... (Code for reading .ods file, cleaning data, and creating the df DataFrame) ...
def display_application_decision():
"""Displays the application decision in an HTML table based on user input."""
application_number = input("Enter your Application Number: ")
try:
application_number = int(application_number)
except ValueError:
print("Invalid input. Please enter a valid application number.")
return
# Find the row corresponding to the entered application number.
row = df[df['Application Number'] == application_number]
if not row.empty:
# Create HTML table string
html_table = """
<html>
<body>
<table>
<tr>
<th>Application Number</th>
<th>Decision</th>
</tr>
<tr>
<td>{}</td>
<td>{}</td>
</tr>
</table>
</body>
</html>
""".format(row['Application Number'].iloc[0], row['Decision'].iloc[0])
# Display the HTML table
display(HTML(html_table))
else:
# Find the nearest records if the exact application number is not found
df['Difference'] = abs(df['Application Number'] - application_number)
nearest_records = df.nsmallest(2, 'Difference')
if not nearest_records.empty:
# Create HTML table string for nearest records
html_table = """
<html>
<body>
<h3>Application number not found. Showing nearest records:</h3>
<table>
<tr>
<th>Application Number</th>
<th>Decision</th>
<th>Difference</th>
</tr>
"""
for _, row in nearest_records.iterrows():
html_table += """
<tr>
<td>{}</td>
<td>{}</td>
<td>{}</td>
</tr>
""".format(row['Application Number'], row['Decision'], row['Difference'])
html_table += """
</table>
</body>
</html>
"""
# Display the HTML table
display(HTML(html_table))
else:
print("Application number not found, and no nearest records found in the data.")
# Call the function to start the process
display_application_decision()
import requests
import pandas as pd
from io import BytesIO
from bs4 import BeautifulSoup
from IPython.display import HTML
#%pip install requests beautifulsoup4
#%pip install pandas odfpy
#%pip install pandas odfpy requests
# ... (Your existing code for fetching and processing the data remains the same) ...
# ... (Code for reading .ods file, cleaning data, and creating the df DataFrame) ...
def display_application_decision():
"""Displays the application decision in an HTML table based on user input."""
application_number = input("Enter your Application Number: ")
try:
application_number = int(application_number)
except ValueError:
print("Invalid input. Please enter a valid application number.")
return
# Find the row corresponding to the entered application number.
row = df[df['Application Number'] == application_number]
if not row.empty:
# Congratulate the user if the application is approved
if row['Decision'].iloc[0] == 'Approved':
print("Congratulations! Your Visa application has been approved.")
# Create HTML table string
html_table = """
<html>
<body>
<table>
<tr>
<th>Application Number</th>
<th>Decision</th>
</tr>
<tr>
<td>{}</td>
<td>{}</td>
</tr>
</table>
</body>
</html>
""".format(row['Application Number'].iloc[0], row['Decision'].iloc[0])
# Display the HTML table
display(HTML(html_table))
else:
print("Application number", application_number, "not found in the data.")
# Find the nearest records if the exact application number is not found
df['Difference'] = abs(df['Application Number'] - application_number)
nearest_records = df.nsmallest(2, 'Difference')
if not nearest_records.empty:
# Create HTML table string for nearest records
html_table = """
<html>
<body>
<h3>Application number not found. Showing nearest records:</h3>
<table>
<tr>
<th>Application Number</th>
<th>Decision</th>
<th>Difference</th>
</tr>
"""
for _, row in nearest_records.iterrows():
html_table += """
<tr>
<td>{}</td>
<td>{}</td>
<td>{}</td>
</tr>
""".format(row['Application Number'], row['Decision'], row['Difference'])
html_table += """
</table>
</body>
</html>
"""
# Display the HTML table
display(HTML(html_table))
else:
print("Application number not found, and no nearest records found in the data.")
# Call the function to start the process
display_application_decision()
# prompt: read the above code and make following changes into it. don't allow user to enter more than 8 numbers and when displaying the result for difference make a tabular form table and maintain gap between decission and diffrence columns.
import requests
import pandas as pd
from io import BytesIO
from bs4 import BeautifulSoup
from IPython.display import HTML
# ... (Your existing code for fetching and processing the data remains the same) ...
# ... (Code for reading .ods file, cleaning data, and creating the df DataFrame) ...
def display_application_decision():
"""Displays the application decision in an HTML table based on user input."""
while True:
application_number = input("Enter your Application Number (maximum 8 digits): ")
if not application_number.isdigit() or len(application_number) > 8:
print("Invalid input. Please enter a valid application number with maximum 8 digits.")
continue
else:
break
try:
application_number = int(application_number)
except ValueError:
print("Invalid input. Please enter a valid application number.")
return
# Find the row corresponding to the entered application number.
row = df[df['Application Number'] == application_number]
if not row.empty:
# Congratulate the user if the application is approved
if row['Decision'].iloc[0] == 'Approved':
print("Congratulations! Your Visa application has been approved.")
# Create HTML table string
html_table = """
<html>
<body>
<table>
<tr>
<th>Application Number</th>
<th>Decision</th>
</tr>
<tr>
<td>{}</td>
<td>{}</td>
</tr>
</table>
</body>
</html>
""".format(row['Application Number'].iloc[0], row['Decision'].iloc[0])
# Display the HTML table
display(HTML(html_table))
else:
print("Application number", application_number, "not found in the data.")
# Find the nearest records if the exact application number is not found
df['Difference'] = abs(df['Application Number'] - application_number)
nearest_records = df.nsmallest(2, 'Difference')
if not nearest_records.empty:
# Create HTML table string for nearest records
html_table = """
<html>
<body>
<h3>Application number not found. Showing nearest records:</h3>
<table>
<tr>
<th>Application Number</th>
<th>Decision</th>
<th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Difference&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
</tr>
"""
for _, row in nearest_records.iterrows():
html_table += """
<tr>
<td>{}</td>
<td>{}</td>
<td>{}</td>
</tr>
""".format(row['Application Number'], row['Decision'], row['Difference'])
html_table += """
</table>
</body>
</html>
"""
# Display the HTML table
display(HTML(html_table))
else:
print("Application number not found, and no nearest records found in the data.")
# Call the function to start the process
display_application_decision()
# prompt: read the above code and make the following changes 1. clear the result of previous run and display only latest result of run. 2. if user enter the number less than 8 then display warning that please enter 8 digit of your VISA application number. 3. if user enter any albhabet then aslo show dont enter alphabet and special charathers in input box. 4. if user enter in Captital leter IRL or in small case IRL then pick only the numbers entered after IRL as user input
# ... (Your existing code for fetching and processing the data remains the same) ...
# ... (Code for reading .ods file, cleaning data, and creating the df DataFrame) ...
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
# Find the row corresponding to the entered application number.
row = df[df['Application Number'] == application_number]
if not row.empty:
# Congratulate the user if the application is approved
if row['Decision'].iloc[0] == 'Approved':
print("Congratulations! Your Visa application has been approved.")
# Create HTML table string
html_table = """
<html>
<body>
<table>
<tr>
<th>Application Number</th>
<th>Decision</th>
</tr>
<tr>
<td>{}</td>
<td>{}</td>
</tr>
</table>
</body>
</html>
""".format(row['Application Number'].iloc[0], row['Decision'].iloc[0])
# Display the HTML table
from IPython.display import clear_output
clear_output(wait=True)
display(HTML(html_table))
else:
print("Application number", application_number, "not found in the data.")
# Find the nearest records if the exact application number is not found
df['Difference'] = abs(df['Application Number'] - application_number)
nearest_records = df.nsmallest(2, 'Difference')
if not nearest_records.empty:
# Create HTML table string for nearest records
html_table = """
<html>
<body>
<h3>Application number not found. Showing nearest records:</h3>
<table>
<tr>
<th>Application Number</th>
<th>Decision</th>
<th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Difference&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
</tr>
"""
for _, row in nearest_records.iterrows():
html_table += """
<tr>
<td>{}</td>
<td>{}</td>
<td>{}</td>
</tr>
""".format(row['Application Number'], row['Decision'], row['Difference'])
html_table += """
</table>
</body>
</html>
"""
# Display the HTML table
from IPython.display import clear_output
clear_output(wait=True)
display(HTML(html_table))
else:
print("Application number not found, and no nearest records found in the data.")
# Call the function to start the process
display_application_decision()
# prompt: Read all the Code files from above and generate one python file to execute.
import requests
import pandas as pd
from io import BytesIO
from bs4 import BeautifulSoup
from IPython.display import HTML
from IPython.display import clear_output
#%pip install requests beautifulsoup4
#%pip install pandas odfpy
#%pip install pandas odfpy requests
# ... (Your existing code for fetching and processing the data remains the same) ...
# ... (Code for reading .ods file, cleaning data, and creating the df DataFrame) ...
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
# Find the row corresponding to the entered application number.
row = df[df['Application Number'] == application_number]
if not row.empty:
# Congratulate the user if the application is approved
if row['Decision'].iloc[0] == 'Approved':
print("Congratulations! Your Visa application has been approved.")
# Create HTML table string
html_table = """
<html>
<body>
<table>
<tr>
<th>Application Number</th>
<th>Decision</th>
</tr>
<tr>
<td>{}</td>
<td>{}</td>
</tr>
</table>
</body>
</html>
""".format(row['Application Number'].iloc[0], row['Decision'].iloc[0])
# Display the HTML table
clear_output(wait=True)
display(HTML(html_table))
else:
print("Application number", application_number, "not found in the data.")
# Find the nearest records if the exact application number is not found
df['Difference'] = abs(df['Application Number'] - application_number)
nearest_records = df.nsmallest(2, 'Difference')
if not nearest_records.empty:
# Create HTML table string for nearest records
html_table = """
<html>
<body>
<h3>Application number not found. Showing nearest records:</h3>
<table>
<tr>
<th>Application Number</th>
<th>Decision</th>
<th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Difference&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
</tr>
"""
for _, row in nearest_records.iterrows():
html_table += """
<tr>
<td>{}</td>
<td>{}</td>
<td>{}</td>
</tr>
""".format(row['Application Number'], row['Decision'], row['Difference'])
html_table += """
</table>
</body>
</html>
"""
# Display the HTML table
clear_output(wait=True)
display(HTML(html_table))
else:
print("Application number not found, and no nearest records found in the data.")
# Call the function to start the process
display_application_decision()