Parcourir la source

fix: handle CSV encoding issues with custom read_csv utility

mrh (aider) il y a 1 an
Parent
commit
a720f9fff4
1 fichiers modifiés avec 3 ajouts et 2 suppressions
  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, '搜索词')