vault backup: 2026-11-06 09:29:04
This commit is contained in:
1 parent
f0f09e1d59
commit
159ff2ba53
12 files changed
+134
-17
No files matched your search
@@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# 读取百家号后台导出的《单篇数据.xlsx》:打印所有 sheet、表头与数据行
|
||||
import sys
|
||||
import openpyxl
|
||||
|
||||
sys.stdout.reconfigure(encoding="utf-8")
|
||||
path = r"E:\Download\单篇数据.xlsx"
|
||||
|
||||
wb = openpyxl.load_workbook(path, data_only=True, read_only=True)
|
||||
print(f"file: {path}")
|
||||
print(f"sheets: {wb.sheetnames}")
|
||||
|
||||
for ws in wb.worksheets:
|
||||
print(f"\n=== SHEET: {ws.title} dims={ws.max_row} rows x {ws.max_column} cols ===")
|
||||
empty_streak = 0
|
||||
for i, row in enumerate(ws.iter_rows(values_only=True), 1):
|
||||
vals = ["" if v is None else str(v).replace("\n", "\\n") for v in row]
|
||||
if not any(vals):
|
||||
empty_streak += 1
|
||||
if empty_streak > 3:
|
||||
continue
|
||||
else:
|
||||
empty_streak = 0
|
||||
print(f"[{i}] " + " | ".join(vals))
|
||||
if i >= 80:
|
||||
print("...(over 80 rows, truncated for inspection)")
|
||||
break
|
||||
wb.close()
|
||||
Reference in new issue
Block a user