Python Json转置为excel

2021-11-18  本文已影响0人  michaelxwang
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 18 21:46:56 2021

@author: michaelxwang
"""

import json
from pandas import json_normalize

filename='./xxx_json.txt'

#打开存储json的文件
with open(filename, 'r',encoding='utf8') as file_to_read:
    data = file_to_read.read()

#load json
result_json = json.loads(data)

#格式化
dat_table = json_normalize(result_json)  

#导出excel
dat_table.to_excel('./xxx.xlsx',index = False)    



上一篇 下一篇

猜你喜欢

热点阅读