|
|
@@ -13,7 +13,7 @@ def create_search_link(value):
|
|
|
|
|
|
def read_csv(file_path):
|
|
|
"""读取CSV文件并返回数据列表"""
|
|
|
- encodings = ['utf-8', 'latin-1', 'gbk']
|
|
|
+ encodings = ['utf-8-sig', 'shift_jis', 'euc-jp', 'utf-16'] # 添加日文常用编码
|
|
|
for encoding in encodings:
|
|
|
try:
|
|
|
with open(file_path, mode='r', encoding=encoding) as file:
|
|
|
@@ -72,7 +72,7 @@ def add_search_links(data, column_index, start_row=0):
|
|
|
def save_csv(data, file_path):
|
|
|
"""将数据保存为CSV文件"""
|
|
|
try:
|
|
|
- with open(file_path, mode='w', newline='', encoding='utf-8') as file:
|
|
|
+ with open(file_path, mode='w', newline='', encoding='utf-8-sig') as file: # 使用utf-8-sig编码
|
|
|
writer = csv.writer(file)
|
|
|
writer.writerows(data)
|
|
|
except Exception as e:
|