|
|
@@ -24,12 +24,16 @@ def insert_empty_columns(data: List[List[str]], column_indices: List[int]) -> Li
|
|
|
logger.error(f"Error inserting empty columns: {e}")
|
|
|
raise
|
|
|
|
|
|
-def extract_sample_data(data: List[List[str]], n: int = 3, m: int = 2) -> List[List[str]]:
|
|
|
- """提取前n行m列数据用于检查"""
|
|
|
+def extract_sample_data(data: List[List[str]], start_row: int = 0, column_index: int = 0, n: int = 3, m: int = 2) -> List[List[str]]:
|
|
|
+ """提取指定行和列开始的样本数据"""
|
|
|
try:
|
|
|
sample = []
|
|
|
- for row in data[:n]:
|
|
|
- sample.append(row[:m])
|
|
|
+ # 确保不超过数据范围
|
|
|
+ end_row = min(start_row + n, len(data))
|
|
|
+ end_col = min(column_index + m, len(data[0]) if data else 0)
|
|
|
+
|
|
|
+ for row in data[start_row:end_row]:
|
|
|
+ sample.append(row[column_index:end_col])
|
|
|
return sample
|
|
|
except Exception as e:
|
|
|
logger.error(f"Error extracting sample data: {e}")
|
|
|
@@ -56,8 +60,8 @@ def process_batch_translations(data: List[List[str]],
|
|
|
"""批量处理搜索词翻译"""
|
|
|
try:
|
|
|
# 首先提取样本数据用于检查
|
|
|
- sample_data = extract_sample_data(data)
|
|
|
- logger.info(f"Sample data extracted for inspection:\n{sample_data}")
|
|
|
+ sample_data = extract_sample_data(data, start_row, search_term_index)
|
|
|
+ logger.info(f"从第{start_row}行第{search_term_index}列开始的样本数据:\n{sample_data}")
|
|
|
|
|
|
# 记录数据详细信息
|
|
|
log_data_details(data, search_term_index, start_row)
|