feat: Initial commit

This commit is contained in:
2024-03-22 17:01:42 +01:00
parent 954985f39a
commit c343ff6e93
106 changed files with 143428 additions and 1 deletions

View File

@@ -0,0 +1,102 @@
from typing import cast
def loadFile(filename: str):
in_file = open(filename, "r")
items = {}
for item in in_file:
ispl = item.split()
iname = ispl[0].strip()
cost = float(ispl[1])
count = int(ispl[2])
items[iname] = [cost, count]
in_file.close()
return items
def saveFile(filename: str, items: dict):
out_file = open(filename, "w")
for key in items:
out_file.write(key + "\t" + str(items[key][0]) + "\t" + str(items[key][1]) + "\n")
out_file.close()
def handleCommand(items: dict):
command = input("Inserisci un comando: ")
if command == "XXXXXX":
return False
command = command.split()
if len(command) != 2:
print("Comando non valido!")
return True
key = command[0]
op = command[1][0]
try:
delta = int(command[1][1:])
except ValueError:
print("Valore numerico non valido")
return True
if key not in items:
print("Il prodotto non è presente nel database!")
return True
if op != "+" and op != "-":
print("Operazione non valida")
return True
oldVal = items[key][1]
if op == "+":
newVal = oldVal + delta
if newVal > 10000:
print("Quantità di prodotto superiore al valore massimo")
return True
items[key][1] = newVal
print("Incrementa la quantità di prodotto", key, "di", delta)
else:
newVal = oldVal - delta
if newVal < 0:
print("Quantità di prodotto non disponibile")
return True
items[key][1] = newVal
print("Decrementa la quantità di prodotto", key, "di", delta)
print("Valore complessivo precedente:", oldVal)
print("Valore complessivo attuale", newVal)
return True
def main():
in_file_name = input("Inserisci il nome del vecchio file: ")
try:
items = loadFile(in_file_name)
except FileNotFoundError:
exit("Errore! File di input non trovato")
except:
exit("File di input malformato!")
while handleCommand(items):
pass
out_file_name = input("Inserisci il nome del nuovo file: ")
try:
saveFile(out_file_name, items)
except FileNotFoundError:
exit("Errore! File di output non trovato")
main()

View File

@@ -0,0 +1,5 @@
ABCD306AZN 20.0 80
AZBF39829B 2.0 1000
AB302EFA 5.0 400
DSKJH34998 0.01 4000
FER3942DDDF 0.5 1000

View File

@@ -0,0 +1,5 @@
ABCD306AZN 20.00 80
AZBF39829B 2.00 1200
AB302EFA 5.00 400
DSKJH34998 0.01 4000
FER3942DDDF 0.5 1000

View File

@@ -0,0 +1 @@
... .. ... .- .-.. ...- .. -.-. .... .. .--. ..- --- -.--.-

View File

@@ -0,0 +1,37 @@
def loadMorse(filename: str, to_ascii: bool):
fio = open(filename, "r")
conv_table = {}
for line in fio:
line = line.split()
if to_ascii:
conv_table[line[1].upper()] = line[0]
else:
conv_table[line[0]] = line[1].upper()
conv_table[" "] = " "
return conv_table
def main():
to_ascii = input("Vuoi decodificare un file? ") == "si"
in_file = input("Inserisci il nome del file: ")
conv_table = loadMorse("morse.txt", to_ascii)
with open(in_file, "r") as fio:
in_str = fio.readline()
if to_ascii:
for char in in_str.split():
print(conv_table[char], end="")
else:
in_str = list(in_str.upper())
for char in in_str:
print(conv_table[char], end=" ")
main()

View File

@@ -0,0 +1,44 @@
A .-
B -...
C -.-.
D -..
E .
F ..-.
G --.
H ....
I ..
J .---
K -.-
L .-..
M --
N -.
O ---
P .--.
Q --.-
R .-.
S ...
T -
U ..-
V ...-
W .--
X -..-
Y -.--
Z --..
, --..--
: ---...
; -.-.-.
. .-.-.-
" .-..-.
( -----.
) .-----
' -.--.-
1 .----
2 ..---
3 ...--
4 ....-
5 .....
6 -....
7 --...
8 ---..
9 ----.
0 -----

View File

@@ -0,0 +1 @@
Si salvi chi puo' forza e coraggio

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,35 @@
import csv
with open("20201214_QDV2020_001.csv") as csv_file:
csv_reader = csv.reader(csv_file)
line_count = 0
rows = []
indc = set()
for row in csv_reader:
if line_count == 0:
print(f'Column names are {", ".join(row)}')
line_count += 1
else:
row_a = {"provincia": row[0], "valore": row[4], "indicatore": row[5]}
indc.add(row[5])
rows.append(row_a)
indc = list(indc)
print("Indicatori della qualità della vita:")
for i in range(len(indc)):
print(str(i+1) + ".", indc[i])
while True:
indic = input("Inserisci l'indicatore: ")
if indic == "quit":
break
indic = indc[int(indic)]
rows_filtered = {}
for r in rows:
if r["indicatore"] == indic