feat: 兼容 xlsx 文件读取 Ticket ID,取消数量限制
This commit is contained in:
@@ -7,7 +7,8 @@
|
|||||||
"Bash(git commit:*)",
|
"Bash(git commit:*)",
|
||||||
"Bash(head:*)",
|
"Bash(head:*)",
|
||||||
"Bash(python3:*)",
|
"Bash(python3:*)",
|
||||||
"Bash(curl -sI \"https://cdn.playwright.dev/chrome-for-testing-public/145.0.7632.6/linux64/chrome-headless-shell-linux64.zip\")"
|
"Bash(curl -sI \"https://cdn.playwright.dev/chrome-for-testing-public/145.0.7632.6/linux64/chrome-headless-shell-linux64.zip\")",
|
||||||
|
"Bash(pip3 show:*)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,23 +30,36 @@ print_lock = threading.Lock()
|
|||||||
# ─────────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|
||||||
def get_ticket_ids(limit=10):
|
def get_ticket_ids():
|
||||||
ids, seen = [], set()
|
ids, seen = [], set()
|
||||||
|
|
||||||
|
def _add(val):
|
||||||
|
val = str(val).strip()
|
||||||
|
if val and val not in seen:
|
||||||
|
seen.add(val)
|
||||||
|
ids.append(val)
|
||||||
|
|
||||||
for csv_file in glob.glob(os.path.join(DATASOURCE, "*.csv")):
|
for csv_file in glob.glob(os.path.join(DATASOURCE, "*.csv")):
|
||||||
with open(csv_file, encoding="utf-8-sig") as f:
|
with open(csv_file, encoding="utf-8-sig") as f:
|
||||||
reader = csv.reader(f)
|
reader = csv.reader(f)
|
||||||
next(reader, None)
|
next(reader, None)
|
||||||
for row in reader:
|
for row in reader:
|
||||||
if len(row) < 2:
|
if len(row) >= 2:
|
||||||
continue
|
_add(row[1])
|
||||||
val = row[1].strip()
|
|
||||||
if val and val not in seen:
|
for xlsx_file in glob.glob(os.path.join(DATASOURCE, "*.xlsx")):
|
||||||
seen.add(val)
|
import openpyxl
|
||||||
ids.append(val)
|
wb = openpyxl.load_workbook(xlsx_file, read_only=True, data_only=True)
|
||||||
if len(ids) >= limit:
|
ws = wb.active
|
||||||
break
|
first = True
|
||||||
if len(ids) >= limit:
|
for row in ws.iter_rows(min_col=2, max_col=2, values_only=True):
|
||||||
break
|
if first:
|
||||||
|
first = False
|
||||||
|
continue
|
||||||
|
if row[0] is not None:
|
||||||
|
_add(row[0])
|
||||||
|
wb.close()
|
||||||
|
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
BIN
datasource/25年10月索赔报表.xlsx
Normal file
BIN
datasource/25年10月索赔报表.xlsx
Normal file
Binary file not shown.
@@ -1,5 +1,6 @@
|
|||||||
requests
|
requests
|
||||||
urllib3
|
urllib3
|
||||||
|
openpyxl
|
||||||
# 可选:Salesforce 外链附件爬取
|
# 可选:Salesforce 外链附件爬取
|
||||||
scrapling[all]
|
scrapling[all]
|
||||||
playwright
|
playwright
|
||||||
|
|||||||
Reference in New Issue
Block a user