Posts

Showing posts with the label Python Coding challenge

Create a CSV file using JSON in Python

Image

Generator function in python programming

Image

Python Programming tutorial and exercise

Image
Python Programming to create a csv file json file example Create a CSV file using a JSON file in python programming # python programming for creating csv from json file # python programming tutorial import json import csv # reading json file using json library in python # converting json into python dictionary # extracting keys from python dictionary with open('student_info.json') as file: data = json.load(file) li = list(data[0].keys()) # creating csv file in python programming # creating csv file in file append mode # writing python list or dictionary into csv file using csv library with open('students.csv', 'a+', newline="") as cfile: writer = csv.writer(cfile) writer.writerow(li) for item in data: row = [item['id'], item['name']] writer.writerow(row) # example of json file [ { "id": 1, "name": "std1" }, { "id": 2, ...