Saving dictionary data in Excel file with Python (2023-09-24 23:24:57)
Excel is one of the most important and widely used software in the field of information storage and processing. Using the features of this software can greatly facilitate the speed of searching, processing and even drawing the necessary data charts.
In the following script, using the openpyxl library, we save the information stored in a dictionary in an Excel file sheet.
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
sheet = wb.create_sheet("Countries",0)
dataDic={
'A1':'Iran',
'A2':'Turkey',
'A3':'Azerbaijan',
}
for item in dataDic:
sheet[item]=(dataDic[item])
wb.save("CountriesList.xlsx")
Comments