Convert JSON to CSV with Python 3

前端 未结 1 855
生来不讨喜
生来不讨喜 2021-01-14 08:11

I need to get some data from the Meetup API, convert the JSON I get into a CSV, all of that in Python 3. I\'ve never worked with JSON or Python, so I\'ve run into some issue

相关标签:
1条回答
  • 2021-01-14 08:45

    To convert the json data to csv you need to extract keys and write them in header and then work on the values. This might help you:

    data_parsed = json.loads(Data)
    
    header = data_parsed[0].keys()
    csv_writer.writerow(header)
    
    for i in range(0,length_data)
        meetup = data_parsed[i].values()
        csv_writer.writerow([meetup])
    
    0 讨论(0)
提交回复
热议问题