Browse Source

fix: handle CSV encoding issues with custom read_csv utility

mrh (aider) 1 year ago
parent
commit
a720f9fff4
1 changed files with 3 additions and 2 deletions
  1. 3 2
      mylib/translate_utils.py

+ 3 - 2
mylib/translate_utils.py

@@ -134,8 +134,9 @@ def main():
     input_file = output_dir/"测试.csv"
     output_file = output_dir/"processed_测试.csv"
     
-    # 读取CSV文件
-    df = pd.read_csv(input_file)
+    # 使用自定义编码检测读取CSV文件
+    data = read_csv(input_file)
+    df = pd.DataFrame(data[1:], columns=data[0])
     
     # 提取列数据
     extract_column_data(df, '搜索词')