import pandas as pd
import json
df = pd.read_excel('./TfidfVectorizer_sklearn.xlsx')
df.to_json('new_file1.json', orient='records') # excel to json
# read json and then append details to it
with open('./new_file1.json', 'r') as json_file:
a = {}
data = json.load(json_file)
a['details'] = data
# write new json with details in it
with open("./new_file1.json", "w") as jsonFile:
json.dump(a, jsonFile)
2条答案
按热度按时间wlwcrazw1#
在问题中考虑了类似的任务:
Converting Excel into JSON using Python
解决这一问题可以有不同的方法。
k0pti3hp2#
我希望,它对你的解决方案有效。
JSON输出: