32 lines
858 B
Python
32 lines
858 B
Python
#!/usr/bin/env python3
|
||
"""从 datasource 目录下的 CSV 文件读取第二列,提取10个有效的 Ticket ID"""
|
||
import csv
|
||
import glob
|
||
import os
|
||
|
||
datasource_dir = os.path.join(os.path.dirname(__file__), "datasource")
|
||
csv_files = glob.glob(os.path.join(datasource_dir, "*.csv"))
|
||
|
||
ids = []
|
||
seen = set()
|
||
|
||
for csv_file in csv_files:
|
||
with open(csv_file, encoding="utf-8-sig") as f:
|
||
reader = csv.reader(f)
|
||
next(reader, None) # 跳过表头
|
||
for row in reader:
|
||
if len(row) < 2:
|
||
continue
|
||
val = row[1].strip()
|
||
if val and val not in seen:
|
||
seen.add(val)
|
||
ids.append(val)
|
||
if len(ids) >= 10:
|
||
break
|
||
if len(ids) >= 10:
|
||
break
|
||
|
||
print("找到的 Ticket ID:")
|
||
for i, tid in enumerate(ids, 1):
|
||
print(f" {i}. {tid}")
|