fatesses 2022-04-22 10:11 采纳率: 50%
浏览 22
已结题

python3 如何解决嵌套json转csv

json文件是嵌套json,目前通过遍历能存在一个list中,我想要将他存到csv中,该怎么办啊?

{"id":"oUtNZ6WK47citf2SLvtvrg_0000","full_name":"user userb","first_name":"user","middle_initial":null,"middle_name":null,"last_name":"userb","gender":null,"birth_year":null,"birth_date":null,"ABC_url":"ABC.com/in/user-userb-6137b646","ABC_username":"user-userb-6137b646","ABC_id":"163224303","facebook_url":null,"facebook_username":null,"facebook_id":null,"twitter_url":null,"twitter_username":null,"github_url":null,"github_username":null,"work_email":null,"mobile_phone":null,"industry":"media production","job_title":"communication officer","job_title_role":null,"job_title_sub_role":null,"job_title_levels":[],"job_company_id":null,"job_company_name":"plan international cambodia","job_company_website":null,"job_company_size":null,"job_company_founded":null,"job_company_industry":null,"job_company_ABC_url":null,"job_company_ABC_id":null,"job_company_facebook_url":null,"job_company_twitter_url":null,"job_company_location_name":null,"job_company_location_locality":null,"job_company_location_metro":null,"job_company_location_region":null,"job_company_location_geo":null,"job_company_location_street_address":null,"job_company_location_address_line_2":null,"job_company_location_postal_code":null,"job_company_location_country":null,"job_company_location_continent":null,"job_last_updated":"2018-12-01","job_start_date":"2010-09","job_summary":null,"location_name":"cambodia","location_locality":null,"location_metro":null,"location_region":null,"location_country":"cambodia","location_continent":"asia","location_street_address":null,"location_address_line_2":null,"location_postal_code":null,"location_geo":null,"location_last_updated":"2018-12-01","ABC_connections":10,"inferred_salary":null,"inferred_years_experience":6,"summary":"Student at Department of Media and Communication","phone_numbers":[],"emails":[{"address":"useruserb@yahoo.com","type":"personal"}],"interests":[],"skills":[],"location_names":[],"regions":[],"countries":["cambodia"],"street_addresses":[],"experience":[{"company":{"name":"plan international cambodia","size":null,"id":null,"founded":null,"industry":null,"location":null,"ABC_url":null,"ABC_id":null,"facebook_url":null,"twitter_url":null,"website":null},"location_names":[],"end_date":null,"start_date":"2010-09","title":{"name":"communication officer","role":null,"sub_role":null,"levels":[]},"is_primary":true,"summary":null}],"education":[{"school":null,"end_date":"2014","start_date":"2010","gpa":null,"degrees":["bachelors","bachelor of arts"],"majors":["media management"],"minors":[],"summary":null}],"profiles":[{"network":"ABC","id":"163224303","url":"userb-6137b646","username":"user-userb-6137b646"}],"certifications":[],"languages":[],"version_status":{"status":"updated","contains":[],"previous_version":"12.0","current_version":"13.0"}}

希望能够成功转csv,至少要指定的key转出来。

  • 写回答

2条回答 默认 最新

  • 陈年椰子 2022-04-22 12:03
    关注

    比如存到 list1 , 用pandas 转成DataFrame就可以存csv了

    import pandas as pd
    df1 =  pd.DataFrame(list1)
    df1.to_csv("data.csv") 
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 4月30日
  • 已采纳回答 4月22日
  • 创建了问题 4月22日

悬赏问题

  • ¥15 微信小程序 用oss下载 aliyun-oss-sdk-6.18.0.min client报错
  • ¥15 ArcGIS批量裁剪
  • ¥15 labview程序设计
  • ¥15 为什么在配置Linux系统的时候执行脚本总是出现E: Failed to fetch http:L/cn.archive.ubuntu.com
  • ¥15 Cloudreve保存用户组存储空间大小时报错
  • ¥15 伪标签为什么不能作为弱监督语义分割的结果?
  • ¥15 编一个判断一个区间范围内的数字的个位数的立方和是否等于其本身的程序在输入第1组数据后卡住了(语言-c语言)
  • ¥15 Mac版Fiddler Everywhere4.0.1提示强制更新
  • ¥15 android 集成sentry上报时报错。
  • ¥15 抖音看过的视频,缓存在哪个文件