我正在使用这个脚本对地址进行地理编码。脚本工作正常,但是输出文件将特殊字符(如中央区
和Athénée
)转换为乱码。i、 e
中央区
->;ä¸å¤®åŒº
Athénée
->;Athénée
输入文件是保存在MAC excel中的UTF-8.CSV文件。脚本正在使用熊猫来处理数据。如何支持上述特殊字符?你知道吗
完整脚本的代码可以在以下位置找到: https://github.com/shanealynn/python_batch_geocode/blob/master/python_batch_geocoding.py
import pandas as pd
import requests
import logging
import time
#------------------ CONFIGURATION -------------------------------
# Set your output file name here.
output_filename = '/Users/_Library/Python/geobatch/res1000_output.csv'
# Set your input file here
input_filename = "/Users/_Library/Python/geobatch/res1000.csv"
# Specify the column name in your input data that contains addresses here
address_column_name = "Address"
# Return Full Google Results? If True, full JSON results from Google are included in output
RETURN_FULL_RESULTS = False
#------------------ DATA LOADING --------------------------------
# Read the data to a Pandas Dataframe
data = pd.read_csv(input_filename, encoding='utf8')
addresses = data[address_column_name].tolist()
# All done
logger.info("Finished geocoding all addresses")
# Write the full results to csv using the pandas library.
pd.DataFrame(results).to_csv(output_filename, encoding='utf8')
显然这就是我正在使用的解决方案:
如果我插入行:
解码和重新编码的输入-然后输出成为。你知道吗
中央区
->;\u4e2d\u592e\u533a
而不是ä¸å¤®åŒº
如果有人能以此为基础的话,我想这离正确的方向又近了一步?你知道吗
相关问题 更多 >
编程相关推荐