美文网首页
Python Json转置为excel

Python Json转置为excel

作者: michaelxwang | 来源:发表于2021-11-18 22:06 被阅读0次
    # -*- 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)    
    
    
    
    

    相关文章

      网友评论

          本文标题:Python Json转置为excel

          本文链接:https://www.haomeiwen.com/subject/knbjtrtx.html