使用pandas实现EXCEL转JSON
import pandas
import json
# 读取EXCEL文件
excel_data_df = pandas.read_excel('data.xlsx', sheet_name='sheet1')
# 使用PANDAS的to_json API直接将EXCEL转化为JSON
thisisjson = excel_data_df.to_json(orient='records')
# 输出要转换的JSON【此时还是一个JSON文件】
print('Excel Sheet to JSON:\n', thisisjson)
# 将JSON文件变成Python对象
thisisjson_dict = json.loads(thisisjson)
# 保存JSON文件
with open('data.json', 'w') as json_file:
json.dump(thisisjson_dict, json_file)