Python ile json’dan Excel’e sorunsuz çeviri yapmak (json to xlsx)

openpyxl kütüphanesini yükledikten sonra aşağıdaki kod blogunu çalıştırarak masaüstündeki bir json soyasını xlsx formatına sorunsuzca çevirebilirsiniz. İyi çalışmalar

import json
from openpyxl import Workbook
 
keys = []
wb = Workbook()
ws = wb.active
 
with open(r'C:\Users\pcadi\Desktop\girdi.json',encoding="utf8") as f:
    json_data = json.load(f)
 
for i in range(len(json_data)) :
	sub_obj = json_data[i]
	if i == 0 :
		keys = list(sub_obj.keys())
		for k in range(len(keys)) :
			# row or column index start from 1
			ws.cell(row = (i + 1), column = (k + 1), value = keys[k]);
	for j in range(len(keys)) :
		ws.cell(row = (i + 2), column = (j + 1), value = sub_obj[keys[j]]);
wb.save(r"C:\Users\pcadi\Desktop\cikti.xlsx")

json to excel, json to xlsx

Bu İçeriğe Puan Verebilirsiniz
[Toplam: 1 Ortalama: 5]

Bir cevap yazın

E-posta hesabınız yayımlanmayacak.

This site uses Akismet to reduce spam. Learn how your comment data is processed.