diff --git a/test_apps/test_app11.py b/test_apps/test_app11.py new file mode 100644 index 0000000..f40931c --- /dev/null +++ b/test_apps/test_app11.py @@ -0,0 +1,97 @@ +import pandas as pd +from flask import Flask, request, render_template_string +import os + +app = Flask(__name__) + +# Directory to store converted CSV files +UPLOAD_FOLDER = 'converted_files' +os.makedirs(UPLOAD_FOLDER, exist_ok=True) + +@app.route('/') +def index(): + return ''' +
Row {adjusted_row_idx}, Column {adjusted_col_idx}: {cell_str}
" + + # Fetch Mail Bag No from rows 4 and 5, columns C and D (non-zero-based indexing) + try: + mail_bag_no_parts = [ + str(df.iloc[3, 2]) if not pd.isna(df.iloc[3, 2]) else "", + str(df.iloc[3, 3]) if not pd.isna(df.iloc[3, 3]) else "" + ] + mail_bag_no = " ".join(part for part in mail_bag_no_parts if part.strip()) + except IndexError: + mail_bag_no = None + + # Break inner loops once tracking number is found + break + if tracking_found: + break + if tracking_found: + break + + # Display the Mail Bag No if found + if tracking_found and mail_bag_no: + result_html += f"Mail Bag No: {mail_bag_no}
" + elif tracking_found: + result_html += f"Mail Bag No: Not found
" + else: + # If no tracking number was found, display a message + result_html += f"No data found for Tracking No: {tracking_no}
" + + return render_template_string(result_html) + + except Exception as e: + return f"Error processing file: {e}", 500 + + +if __name__ == '__main__': + app.run(debug=True, port=5000, host='0.0.0.0')