#!/usr/bin/env python3
"""探索所有 L>0 的行（不限 D 欄），以及 2/8 休息日的詳細欄位"""
from google.oauth2 import service_account
from googleapiclient.discovery import build

SPREADSHEET_ID = '1Y708RZgZHL3Gqah9ujiw5brMuxAoW3RFl0txfXq8qrE'
creds = service_account.Credentials.from_service_account_file(
    'service_account_key.json',
    scopes=['https://www.googleapis.com/auth/spreadsheets']
)
service = build('sheets', 'v4', credentials=creds)

for month in ['2026.01', '2026.02', '2026.03']:
    print(f'\n{"="*60}')
    print(f'=== {month} L>0 的所有行 ===')
    res = service.spreadsheets().values().get(
        spreadsheetId=SPREADSHEET_ID,
        range=f'{month}!A1:O200'
    ).execute()
    rows = res.get('values', [])
    for i, row in enumerate(rows[1:], 2):
        while len(row) < 15:
            row.append('')
        l_val = row[11]
        try:
            l_h = float(l_val) if l_val else 0
        except:
            l_h = 0
        if l_h > 0:
            print(f"  row{i}: B={row[1]!r:14s} D={row[3]!r:18s} E={row[4]!r:6s} F={row[5]!r:6s} "
                  f"G={row[6]!r:30s} H={row[7]!r:6s} I={row[8]!r:4s} K={row[10]!r:6s} L={row[11]!r:6s} O={row[14]!r}")
