import os
import sys
import pandas as pd


def main() -> int:
    os.environ.setdefault("PYTHONIOENCODING", "utf-8")
    path = r"D:\Downloads\CONTROL PLAN DEFECT HPML REV (1).xlsx"
    xl = pd.ExcelFile(path)
    print("sheets:", xl.sheet_names)

    for sh in xl.sheet_names[:10]:
        df = xl.parse(sh, nrows=5)
        print("\n==", sh, "==")
        print("columns:", [str(c) for c in df.columns])
        # Print preview safely (avoid console encoding issues)
        s = df.head(3).astype(str).to_string(index=False)
        sys.stdout.buffer.write((s + "\n").encode("utf-8", "replace"))

    return 0


if __name__ == "__main__":
    raise SystemExit(main())

