diff --git a/Open .Orders WIZ New.xlsb b/Open .Orders WIZ New.xlsb new file mode 100644 index 0000000..766c994 Binary files /dev/null and b/Open .Orders WIZ New.xlsb differ diff --git a/view_dashboard.py b/view_dashboard.py new file mode 100755 index 0000000..d0f31d2 --- /dev/null +++ b/view_dashboard.py @@ -0,0 +1,185 @@ +#!/usr/bin/env python3 +""" +Excel Dashboard Viewer +Reads and displays the Dashboard sheet from Open .Orders WIZ New.xlsb +""" + +import pandas as pd +import sys +import os + +def view_dashboard(file_path): + """View the Dashboard sheet from the Excel file""" + + if not os.path.exists(file_path): + print(f"āŒ File not found: {file_path}") + return + + try: + print("=" * 80) + print(f"šŸ“Š Loading Excel file: {os.path.basename(file_path)}") + print("=" * 80) + + # First, list all sheets in the file + print("\nšŸ“‹ Available sheets:") + xls = pd.ExcelFile(file_path, engine='pyxlsb') + for i, sheet in enumerate(xls.sheet_names, 1): + print(f" {i}. {sheet}") + + # Try to find and read Daily Mirror sheet + dashboard_sheet = None + for sheet in xls.sheet_names: + if 'daily mirror' in sheet.lower() or 'dashboard' in sheet.lower() or 'dash' in sheet.lower(): + dashboard_sheet = sheet + break + + if not dashboard_sheet: + print("\nāš ļø No 'Dashboard' sheet found. Available sheets listed above.") + print("\nPlease select a sheet to view (enter number or name):") + choice = input("> ").strip() + + if choice.isdigit(): + idx = int(choice) - 1 + if 0 <= idx < len(xls.sheet_names): + dashboard_sheet = xls.sheet_names[idx] + else: + if choice in xls.sheet_names: + dashboard_sheet = choice + + if not dashboard_sheet: + print("āŒ Invalid selection") + return + + print(f"\nšŸ“Š Reading sheet: {dashboard_sheet}") + print("=" * 80) + + # Read the sheet + df = pd.read_excel(file_path, sheet_name=dashboard_sheet, engine='pyxlsb') + + # Display basic info + print(f"\nšŸ“ Sheet dimensions: {df.shape[0]} rows Ɨ {df.shape[1]} columns") + print(f"\nšŸ“‹ Column names:") + for i, col in enumerate(df.columns, 1): + print(f" {i}. {col}") + + # Display first few rows + print(f"\nšŸ“Š First 10 rows:") + print("-" * 80) + pd.set_option('display.max_columns', None) + pd.set_option('display.width', None) + pd.set_option('display.max_colwidth', 50) + print(df.head(10).to_string()) + + # Display data types + print(f"\nšŸ“ Data types:") + print(df.dtypes) + + # Display summary statistics for numeric columns + numeric_cols = df.select_dtypes(include=['number']).columns + if len(numeric_cols) > 0: + print(f"\nšŸ“ˆ Summary statistics (numeric columns):") + print(df[numeric_cols].describe()) + + # Check for date columns + date_cols = [] + for col in df.columns: + if 'date' in col.lower(): + date_cols.append(col) + + if date_cols: + print(f"\nšŸ“… Date columns found: {', '.join(date_cols)}") + for col in date_cols: + try: + df[col] = pd.to_datetime(df[col], errors='coerce') + print(f" {col}: {df[col].min()} to {df[col].max()}") + except: + pass + + # Interactive menu + while True: + print("\n" + "=" * 80) + print("šŸ“‹ Options:") + print(" 1. View more rows") + print(" 2. Filter data") + print(" 3. View specific columns") + print(" 4. Export to CSV") + print(" 5. View another sheet") + print(" 6. Exit") + print("=" * 80) + + choice = input("Select option (1-6): ").strip() + + if choice == '1': + n = input("How many rows to display? (default 20): ").strip() + n = int(n) if n.isdigit() else 20 + print(df.head(n).to_string()) + + elif choice == '2': + print(f"Available columns: {', '.join(df.columns)}") + col = input("Enter column name to filter: ").strip() + if col in df.columns: + print(f"Unique values in {col}:") + print(df[col].value_counts().head(20)) + val = input(f"Enter value to filter {col}: ").strip() + filtered = df[df[col].astype(str).str.contains(val, case=False, na=False)] + print(f"\nFiltered results ({len(filtered)} rows):") + print(filtered.to_string()) + else: + print("āŒ Column not found") + + elif choice == '3': + print(f"Available columns: {', '.join(df.columns)}") + cols = input("Enter column names (comma-separated): ").strip() + col_list = [c.strip() for c in cols.split(',')] + valid_cols = [c for c in col_list if c in df.columns] + if valid_cols: + print(df[valid_cols].head(20).to_string()) + else: + print("āŒ No valid columns found") + + elif choice == '4': + output_file = input("Enter output filename (default: dashboard_export.csv): ").strip() + output_file = output_file if output_file else "dashboard_export.csv" + df.to_csv(output_file, index=False) + print(f"āœ… Exported to {output_file}") + + elif choice == '5': + print("\nšŸ“‹ Available sheets:") + for i, sheet in enumerate(xls.sheet_names, 1): + print(f" {i}. {sheet}") + sheet_choice = input("Select sheet (number or name): ").strip() + + if sheet_choice.isdigit(): + idx = int(sheet_choice) - 1 + if 0 <= idx < len(xls.sheet_names): + dashboard_sheet = xls.sheet_names[idx] + df = pd.read_excel(file_path, sheet_name=dashboard_sheet, engine='pyxlsb') + print(f"\nšŸ“Š Loaded sheet: {dashboard_sheet}") + print(f"Dimensions: {df.shape[0]} rows Ɨ {df.shape[1]} columns") + print(df.head(10).to_string()) + else: + if sheet_choice in xls.sheet_names: + df = pd.read_excel(file_path, sheet_name=sheet_choice, engine='pyxlsb') + print(f"\nšŸ“Š Loaded sheet: {sheet_choice}") + print(f"Dimensions: {df.shape[0]} rows Ɨ {df.shape[1]} columns") + print(df.head(10).to_string()) + + elif choice == '6': + print("šŸ‘‹ Goodbye!") + break + + else: + print("āŒ Invalid option") + + except Exception as e: + print(f"āŒ Error reading file: {e}") + import traceback + traceback.print_exc() + +if __name__ == "__main__": + file_path = "/srv/quality_app/Open .Orders WIZ New.xlsb" + + if len(sys.argv) > 1: + file_path = sys.argv[1] + + view_dashboard(file_path)