March 15, 2022 - 9:51pm — theano7203
In case you have csv files and due to events or just life need to organize or move things to the cloud
A regular csv file with Python can convert to Python language and you can manipulate data
CSV looks like this
Rank,Country,Gold,Silver,Bronze,Total
1,United States,39,41,33,113
2,China,38,32,18,88
3,Japan,27,14,17,58
4,Great Britain,22,21,22,65
5,ROC,20,28,23,71
6,Australia,17,7,22,46
7,Netherlands,10,12,14,36
8,France,10,12,11,33
9,Germany,10,11,16,37
10,Italy,10,10,20,40
With dictwriter command in Python
import csv
medals_table = [
{'country': 'United States', 'gold': 39, 'silver': 41, 'bronze': 33, 'rank': 1},
{'country': 'China', 'gold': 38, 'silver': 32, 'bronze': 18, 'rank': 2},
{'country': 'Japan', 'gold': 27, 'silver': 14, 'bronze': 17, 'rank': 3},
{'country': 'Great Britain', 'gold': 22, 'silver': 21, 'bronze': 22, 'rank': 4},
{'country': 'ROC', 'gold': 20, 'silver': 28, 'bronze': 23, 'rank': 5},
{'country': 'Australia', 'gold': 17, 'silver': 7, 'bronze': 22, 'rank': 6},
{'country': 'Netherlands', 'gold': 10, 'silver': 12, 'bronze': 14, 'rank': 7},
{'country': 'France', 'gold': 10, 'silver': 12, 'bronze': 11, 'rank': 8},
{'country': 'Germany', 'gold': 10, 'silver': 11, 'bronze': 16, 'rank': 9},
{'country': 'Italy', 'gold': 10, 'silver': 10, 'bronze': 20, 'rank': 10},
]
def sort_key(d: dict) -> str:
return d['country']
columns = ['country', 'gold', 'silver', 'bronze', 'rank']
filename = 'country_medals.csv'
with open(filename,'w', encoding='utf-8', newline='') as output_file:
writer = csv.DictWriter(output_file, fieldnames=columns, extrasaction= 'ignore')
writer.writeheader()
# for row in medals_table:
# writer.writerow(row)
writer.writerows(sorted(medals_table, key= sort_key))
Where the hash tags are you can take off the last line and it does it a different way on a separate file
you load a csv file and then create a Python file
September 6, 2021 - 1:10am — theano7203
When do those groups show up because without them we would not have art here on the Internet or even here. Always there underneath providing the framework of what will be in the space taken or given.
try:
import tkinter
except ImportError: # python 2
import Tkinter as tkinter
import os
mainWindow = tkinter.Tk()
mainWindow.title("Grid Demo")
mainWindow.geometry('640x480-8-200')
label = tkinter.Label(mainWindow, text="Tkinter Grid Demo")
label.grid(row=0, column=0, columnspan=3)
mainWindow.columnconfigure(0, weight=1)
mainWindow.columnconfigure(1, weight=1)
mainWindow.columnconfigure(2, weight=3)
mainWindow.columnconfigure(3, weight=3)
mainWindow.columnconfigure(4, weight=3)
mainWindow.rowconfigure(0, weight=1)
mainWindow.rowconfigure(1, weight=10)
mainWindow.rowconfigure(2, weight=1)
mainWindow.rowconfigure(3, weight=3)
mainWindow.rowconfigure(4, weight=3)
fileList = tkinter.Listbox(mainWindow)
fileList.grid(row=1, column=0, sticky="nsew", rowspan=2)
fileList.config(border=2, relief="sunken")
for zone in os.listdir('/Windows/System32'):
fileList.insert(tkinter.END, zone)
mainWindow.mainloop()
image.png