In [1]:
2+2
Out[1]:
In [2]:
import os.path
filename=os.path.join("data","rncedificidefinitivo_.csv")
data=open(filename,"r")
print("Opening",filename)
lines=data.readlines()
data.close()
print("Reading done.")
print("Checking file...")
line=1
uti=0
amounts={"Ottimo":0,"Buono":0,"Mediocre":0}
stato = list(amounts.keys())
#ott=0
#buo=0
#med=0
n_a=0
for l in lines:
if "Utilizzato" in l:
#print("match!")
uti+=1
other=True
for s in stato:
if s in l:
other=False
amounts[s]+=1
#if "Ottimo" in l:
# ott+=1
# other=False
#if "Mediocre" in l:
# med+=1
# other=False
#if "Buono" in l:
# buo+=1
# other=False
if other:
n_a+=1
line+=1
print("Basta!")
text="""I checked {} buildings. {} are in use.
The percentage of properties in use is: {:.2f}%.
Out of the used buildings, {} are in great shape, {} are in good shape and
{} are mediocre.
The respective percentages are {:.2f}%, {:.2f}% and {:.2f}%.
{} of the buildings have no valuation.""".format(line,uti,uti/line*100,amounts["Ottimo"],amounts["Buono"],amounts["Mediocre"],amounts["Ottimo"]/uti*100,amounts["Buono"]/uti*100,amounts["Mediocre"]/uti*100,n_a)
print(text)
file=open("05_edificato2.md","w")
file.write(text)
file.close()
In [ ]: