_check_input.py
1 KB
import pandas as pd
f = r'd:/work1/data-analyze-webui/temp_uploads/batch/20260724/hm_sub_brand_主机厂数据-鸿蒙子品牌-模板001_084235.xlsx'
xl = pd.ExcelFile(f)
with open('_input_check.txt', 'w', encoding='utf-8') as out:
out.write(f'Sheets: {xl.sheet_names}\n')
for sn in xl.sheet_names:
df = pd.read_excel(f, sheet_name=sn, header=None)
out.write(f'\nSheet [{sn}]: shape={df.shape}\n')
for r in range(min(6, len(df))):
row_data = [str(df.iloc[r,c])[:25] if pd.notna(df.iloc[r,c]) else '_' for c in range(min(15, df.shape[1]))]
out.write(f'Row {r}: {row_data}\n')
non_empty = sum(1 for i in range(3, len(df)) if pd.notna(df.iloc[i, 3]) and str(df.iloc[i,3]).strip() not in ('','nan','None'))
out.write(f'Data rows: {non_empty}\n')
last = len(df)-1
last_row = [str(df.iloc[last,c])[:25] if pd.notna(df.iloc[last,c]) else '_' for c in range(min(15, df.shape[1]))]
out.write(f'Row {last}: {last_row}\n')