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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """Copy of Visa_decision.ipynb
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1adoBwMAeDiJsePxTmnMcatkjYw3RyJpm
8
+ """
9
+
10
+ #%pip install requests beautifulsoup4
11
+ #%pip install pandas odfpy
12
+ #%pip install pandas odfpy requests
13
+
14
+ import requests
15
+ import pandas as pd
16
+ from io import BytesIO
17
+ from bs4 import BeautifulSoup
18
+
19
+ # ... (Your existing code for fetching and processing the data remains the same) ...
20
+
21
+ # ... (Code for reading .ods file, cleaning data, and creating the df DataFrame) ...
22
+
23
+
24
+ def display_application_decision():
25
+ """Displays the application decision in an HTML table based on user input."""
26
+
27
+ application_number = input("Enter your Application Number: ")
28
+
29
+ try:
30
+ application_number = int(application_number)
31
+ except ValueError:
32
+ print("Invalid input. Please enter a valid application number.")
33
+ return
34
+
35
+ # Find the row corresponding to the entered application number.
36
+ row = df[df['Application Number'] == application_number]
37
+
38
+ if not row.empty:
39
+ # Create HTML table string
40
+ html_table = """
41
+ <html>
42
+ <body>
43
+ <table>
44
+ <tr>
45
+ <th>Application Number</th>
46
+ <th>Decision</th>
47
+ </tr>
48
+ <tr>
49
+ <td>{}</td>
50
+ <td>{}</td>
51
+ </tr>
52
+ </table>
53
+ </body>
54
+ </html>
55
+ """.format(row['Application Number'].iloc[0], row['Decision'].iloc[0])
56
+
57
+ # Display the HTML table
58
+ from IPython.display import HTML
59
+ display(HTML(html_table))
60
+ else:
61
+ print("Application number not found in the data.")
62
+
63
+
64
+ # Call the function to start the process
65
+ display_application_decision()
66
+
67
+
68
+
69
+ import requests
70
+ import pandas as pd
71
+ from io import BytesIO
72
+ from bs4 import BeautifulSoup
73
+ from IPython.display import HTML
74
+
75
+ # ... (Your existing code for fetching and processing the data remains the same) ...
76
+
77
+ # ... (Code for reading .ods file, cleaning data, and creating the df DataFrame) ...
78
+
79
+
80
+ def display_application_decision():
81
+ """Displays the application decision in an HTML table based on user input."""
82
+
83
+ application_number = input("Enter your Application Number: ")
84
+
85
+ try:
86
+ application_number = int(application_number)
87
+ except ValueError:
88
+ print("Invalid input. Please enter a valid application number.")
89
+ return
90
+
91
+ # Find the row corresponding to the entered application number.
92
+ row = df[df['Application Number'] == application_number]
93
+
94
+ if not row.empty:
95
+ # Create HTML table string
96
+ html_table = """
97
+ <html>
98
+ <body>
99
+ <table>
100
+ <tr>
101
+ <th>Application Number</th>
102
+ <th>Decision</th>
103
+ </tr>
104
+ <tr>
105
+ <td>{}</td>
106
+ <td>{}</td>
107
+ </tr>
108
+ </table>
109
+ </body>
110
+ </html>
111
+ """.format(row['Application Number'].iloc[0], row['Decision'].iloc[0])
112
+
113
+ # Display the HTML table
114
+ display(HTML(html_table))
115
+ else:
116
+ # Find the nearest records if the exact application number is not found
117
+ df['Difference'] = abs(df['Application Number'] - application_number)
118
+ nearest_records = df.nsmallest(2, 'Difference')
119
+
120
+ if not nearest_records.empty:
121
+ # Create HTML table string for nearest records
122
+ html_table = """
123
+ <html>
124
+ <body>
125
+ <h3>Application number not found. Showing nearest records:</h3>
126
+ <table>
127
+ <tr>
128
+ <th>Application Number</th>
129
+ <th>Decision</th>
130
+ <th>Difference</th>
131
+ </tr>
132
+ """
133
+ for _, row in nearest_records.iterrows():
134
+ html_table += """
135
+ <tr>
136
+ <td>{}</td>
137
+ <td>{}</td>
138
+ <td>{}</td>
139
+ </tr>
140
+ """.format(row['Application Number'], row['Decision'], row['Difference'])
141
+
142
+ html_table += """
143
+ </table>
144
+ </body>
145
+ </html>
146
+ """
147
+ # Display the HTML table
148
+ display(HTML(html_table))
149
+ else:
150
+ print("Application number not found, and no nearest records found in the data.")
151
+
152
+
153
+ # Call the function to start the process
154
+ display_application_decision()
155
+
156
+ import requests
157
+ import pandas as pd
158
+ from io import BytesIO
159
+ from bs4 import BeautifulSoup
160
+ from IPython.display import HTML
161
+ #%pip install requests beautifulsoup4
162
+ #%pip install pandas odfpy
163
+ #%pip install pandas odfpy requests
164
+
165
+
166
+ # ... (Your existing code for fetching and processing the data remains the same) ...
167
+
168
+ # ... (Code for reading .ods file, cleaning data, and creating the df DataFrame) ...
169
+
170
+
171
+ def display_application_decision():
172
+ """Displays the application decision in an HTML table based on user input."""
173
+
174
+ application_number = input("Enter your Application Number: ")
175
+
176
+ try:
177
+ application_number = int(application_number)
178
+ except ValueError:
179
+ print("Invalid input. Please enter a valid application number.")
180
+ return
181
+
182
+ # Find the row corresponding to the entered application number.
183
+ row = df[df['Application Number'] == application_number]
184
+
185
+ if not row.empty:
186
+ # Congratulate the user if the application is approved
187
+ if row['Decision'].iloc[0] == 'Approved':
188
+ print("Congratulations! Your Visa application has been approved.")
189
+
190
+ # Create HTML table string
191
+ html_table = """
192
+ <html>
193
+ <body>
194
+ <table>
195
+ <tr>
196
+ <th>Application Number</th>
197
+ <th>Decision</th>
198
+ </tr>
199
+ <tr>
200
+ <td>{}</td>
201
+ <td>{}</td>
202
+ </tr>
203
+ </table>
204
+ </body>
205
+ </html>
206
+ """.format(row['Application Number'].iloc[0], row['Decision'].iloc[0])
207
+
208
+ # Display the HTML table
209
+ display(HTML(html_table))
210
+ else:
211
+ print("Application number", application_number, "not found in the data.")
212
+
213
+ # Find the nearest records if the exact application number is not found
214
+ df['Difference'] = abs(df['Application Number'] - application_number)
215
+ nearest_records = df.nsmallest(2, 'Difference')
216
+
217
+ if not nearest_records.empty:
218
+ # Create HTML table string for nearest records
219
+ html_table = """
220
+ <html>
221
+ <body>
222
+ <h3>Application number not found. Showing nearest records:</h3>
223
+ <table>
224
+ <tr>
225
+ <th>Application Number</th>
226
+ <th>Decision</th>
227
+ <th>Difference</th>
228
+ </tr>
229
+ """
230
+ for _, row in nearest_records.iterrows():
231
+ html_table += """
232
+ <tr>
233
+ <td>{}</td>
234
+ <td>{}</td>
235
+ <td>{}</td>
236
+ </tr>
237
+ """.format(row['Application Number'], row['Decision'], row['Difference'])
238
+
239
+ html_table += """
240
+ </table>
241
+ </body>
242
+ </html>
243
+ """
244
+ # Display the HTML table
245
+ display(HTML(html_table))
246
+ else:
247
+ print("Application number not found, and no nearest records found in the data.")
248
+
249
+
250
+ # Call the function to start the process
251
+ display_application_decision()
252
+
253
+ # 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.
254
+
255
+ import requests
256
+ import pandas as pd
257
+ from io import BytesIO
258
+ from bs4 import BeautifulSoup
259
+ from IPython.display import HTML
260
+
261
+ # ... (Your existing code for fetching and processing the data remains the same) ...
262
+
263
+ # ... (Code for reading .ods file, cleaning data, and creating the df DataFrame) ...
264
+
265
+
266
+ def display_application_decision():
267
+ """Displays the application decision in an HTML table based on user input."""
268
+
269
+ while True:
270
+ application_number = input("Enter your Application Number (maximum 8 digits): ")
271
+
272
+ if not application_number.isdigit() or len(application_number) > 8:
273
+ print("Invalid input. Please enter a valid application number with maximum 8 digits.")
274
+ continue
275
+ else:
276
+ break
277
+
278
+ try:
279
+ application_number = int(application_number)
280
+ except ValueError:
281
+ print("Invalid input. Please enter a valid application number.")
282
+ return
283
+
284
+ # Find the row corresponding to the entered application number.
285
+ row = df[df['Application Number'] == application_number]
286
+
287
+ if not row.empty:
288
+ # Congratulate the user if the application is approved
289
+ if row['Decision'].iloc[0] == 'Approved':
290
+ print("Congratulations! Your Visa application has been approved.")
291
+
292
+ # Create HTML table string
293
+ html_table = """
294
+ <html>
295
+ <body>
296
+ <table>
297
+ <tr>
298
+ <th>Application Number</th>
299
+ <th>Decision</th>
300
+ </tr>
301
+ <tr>
302
+ <td>{}</td>
303
+ <td>{}</td>
304
+ </tr>
305
+ </table>
306
+ </body>
307
+ </html>
308
+ """.format(row['Application Number'].iloc[0], row['Decision'].iloc[0])
309
+
310
+ # Display the HTML table
311
+ display(HTML(html_table))
312
+ else:
313
+ print("Application number", application_number, "not found in the data.")
314
+
315
+ # Find the nearest records if the exact application number is not found
316
+ df['Difference'] = abs(df['Application Number'] - application_number)
317
+ nearest_records = df.nsmallest(2, 'Difference')
318
+
319
+ if not nearest_records.empty:
320
+ # Create HTML table string for nearest records
321
+ html_table = """
322
+ <html>
323
+ <body>
324
+ <h3>Application number not found. Showing nearest records:</h3>
325
+ <table>
326
+ <tr>
327
+ <th>Application Number</th>
328
+ <th>Decision</th>
329
+ <th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Difference&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
330
+ </tr>
331
+ """
332
+ for _, row in nearest_records.iterrows():
333
+ html_table += """
334
+ <tr>
335
+ <td>{}</td>
336
+ <td>{}</td>
337
+ <td>{}</td>
338
+ </tr>
339
+ """.format(row['Application Number'], row['Decision'], row['Difference'])
340
+
341
+ html_table += """
342
+ </table>
343
+ </body>
344
+ </html>
345
+ """
346
+ # Display the HTML table
347
+ display(HTML(html_table))
348
+ else:
349
+ print("Application number not found, and no nearest records found in the data.")
350
+
351
+
352
+ # Call the function to start the process
353
+ display_application_decision()
354
+
355
+ # 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
356
+
357
+ # ... (Your existing code for fetching and processing the data remains the same) ...
358
+
359
+ # ... (Code for reading .ods file, cleaning data, and creating the df DataFrame) ...
360
+
361
+
362
+ def display_application_decision():
363
+ """Displays the application decision in an HTML table based on user input."""
364
+
365
+ while True:
366
+ application_number_input = input("Enter your Application Number (including IRL if applicable): ")
367
+ if "irl" in application_number_input.lower():
368
+ try:
369
+ application_number = int("".join(filter(str.isdigit, application_number_input.lower().split("irl")[-1])))
370
+ if len(str(application_number)) < 8:
371
+ print("Please enter a valid application number with minimum 8 digits after IRL.")
372
+ continue
373
+ break
374
+ except ValueError:
375
+ print("Invalid input after IRL. Please enter only digits.")
376
+ continue
377
+
378
+ else:
379
+ if not application_number_input.isdigit():
380
+ print("Invalid input. Please enter only digits.")
381
+ continue
382
+ elif len(application_number_input) < 8:
383
+ print("Please enter at least 8 digits for your VISA application number.")
384
+ continue
385
+ else:
386
+ application_number = int(application_number_input)
387
+ break
388
+
389
+ # Find the row corresponding to the entered application number.
390
+ row = df[df['Application Number'] == application_number]
391
+
392
+ if not row.empty:
393
+ # Congratulate the user if the application is approved
394
+ if row['Decision'].iloc[0] == 'Approved':
395
+ print("Congratulations! Your Visa application has been approved.")
396
+
397
+ # Create HTML table string
398
+ html_table = """
399
+ <html>
400
+ <body>
401
+ <table>
402
+ <tr>
403
+ <th>Application Number</th>
404
+ <th>Decision</th>
405
+ </tr>
406
+ <tr>
407
+ <td>{}</td>
408
+ <td>{}</td>
409
+ </tr>
410
+ </table>
411
+ </body>
412
+ </html>
413
+ """.format(row['Application Number'].iloc[0], row['Decision'].iloc[0])
414
+
415
+ # Display the HTML table
416
+ from IPython.display import clear_output
417
+ clear_output(wait=True)
418
+ display(HTML(html_table))
419
+ else:
420
+ print("Application number", application_number, "not found in the data.")
421
+
422
+ # Find the nearest records if the exact application number is not found
423
+ df['Difference'] = abs(df['Application Number'] - application_number)
424
+ nearest_records = df.nsmallest(2, 'Difference')
425
+
426
+ if not nearest_records.empty:
427
+ # Create HTML table string for nearest records
428
+ html_table = """
429
+ <html>
430
+ <body>
431
+ <h3>Application number not found. Showing nearest records:</h3>
432
+ <table>
433
+ <tr>
434
+ <th>Application Number</th>
435
+ <th>Decision</th>
436
+ <th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Difference&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
437
+ </tr>
438
+ """
439
+ for _, row in nearest_records.iterrows():
440
+ html_table += """
441
+ <tr>
442
+ <td>{}</td>
443
+ <td>{}</td>
444
+ <td>{}</td>
445
+ </tr>
446
+ """.format(row['Application Number'], row['Decision'], row['Difference'])
447
+
448
+ html_table += """
449
+ </table>
450
+ </body>
451
+ </html>
452
+ """
453
+ # Display the HTML table
454
+ from IPython.display import clear_output
455
+ clear_output(wait=True)
456
+ display(HTML(html_table))
457
+ else:
458
+ print("Application number not found, and no nearest records found in the data.")
459
+
460
+
461
+ # Call the function to start the process
462
+ display_application_decision()
463
+
464
+ # prompt: Read all the Code files from above and generate one python file to execute.
465
+
466
+ import requests
467
+ import pandas as pd
468
+ from io import BytesIO
469
+ from bs4 import BeautifulSoup
470
+ from IPython.display import HTML
471
+ from IPython.display import clear_output
472
+
473
+ #%pip install requests beautifulsoup4
474
+ #%pip install pandas odfpy
475
+ #%pip install pandas odfpy requests
476
+
477
+
478
+ # ... (Your existing code for fetching and processing the data remains the same) ...
479
+
480
+ # ... (Code for reading .ods file, cleaning data, and creating the df DataFrame) ...
481
+
482
+
483
+ def display_application_decision():
484
+ """Displays the application decision in an HTML table based on user input."""
485
+
486
+ while True:
487
+ application_number_input = input("Enter your Application Number (including IRL if applicable): ")
488
+ if "irl" in application_number_input.lower():
489
+ try:
490
+ application_number = int("".join(filter(str.isdigit, application_number_input.lower().split("irl")[-1])))
491
+ if len(str(application_number)) < 8:
492
+ print("Please enter a valid application number with minimum 8 digits after IRL.")
493
+ continue
494
+ break
495
+ except ValueError:
496
+ print("Invalid input after IRL. Please enter only digits.")
497
+ continue
498
+
499
+ else:
500
+ if not application_number_input.isdigit():
501
+ print("Invalid input. Please enter only digits.")
502
+ continue
503
+ elif len(application_number_input) < 8:
504
+ print("Please enter at least 8 digits for your VISA application number.")
505
+ continue
506
+ else:
507
+ application_number = int(application_number_input)
508
+ break
509
+
510
+ # Find the row corresponding to the entered application number.
511
+ row = df[df['Application Number'] == application_number]
512
+
513
+ if not row.empty:
514
+ # Congratulate the user if the application is approved
515
+ if row['Decision'].iloc[0] == 'Approved':
516
+ print("Congratulations! Your Visa application has been approved.")
517
+
518
+ # Create HTML table string
519
+ html_table = """
520
+ <html>
521
+ <body>
522
+ <table>
523
+ <tr>
524
+ <th>Application Number</th>
525
+ <th>Decision</th>
526
+ </tr>
527
+ <tr>
528
+ <td>{}</td>
529
+ <td>{}</td>
530
+ </tr>
531
+ </table>
532
+ </body>
533
+ </html>
534
+ """.format(row['Application Number'].iloc[0], row['Decision'].iloc[0])
535
+
536
+ # Display the HTML table
537
+ clear_output(wait=True)
538
+ display(HTML(html_table))
539
+ else:
540
+ print("Application number", application_number, "not found in the data.")
541
+
542
+ # Find the nearest records if the exact application number is not found
543
+ df['Difference'] = abs(df['Application Number'] - application_number)
544
+ nearest_records = df.nsmallest(2, 'Difference')
545
+
546
+ if not nearest_records.empty:
547
+ # Create HTML table string for nearest records
548
+ html_table = """
549
+ <html>
550
+ <body>
551
+ <h3>Application number not found. Showing nearest records:</h3>
552
+ <table>
553
+ <tr>
554
+ <th>Application Number</th>
555
+ <th>Decision</th>
556
+ <th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Difference&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
557
+ </tr>
558
+ """
559
+ for _, row in nearest_records.iterrows():
560
+ html_table += """
561
+ <tr>
562
+ <td>{}</td>
563
+ <td>{}</td>
564
+ <td>{}</td>
565
+ </tr>
566
+ """.format(row['Application Number'], row['Decision'], row['Difference'])
567
+
568
+ html_table += """
569
+ </table>
570
+ </body>
571
+ </html>
572
+ """
573
+ # Display the HTML table
574
+ clear_output(wait=True)
575
+ display(HTML(html_table))
576
+ else:
577
+ print("Application number not found, and no nearest records found in the data.")
578
+
579
+
580
+ # Call the function to start the process
581
+ display_application_decision()