added some description to functions

master
putro 2020-04-17 16:43:36 +02:00
parent f4b7e6a887
commit 8b0c518be1
2 changed files with 5 additions and 2 deletions

2
README
View File

@ -39,7 +39,7 @@ ogni volta che si lancia lo script viene salvato un file export.csv che contiene
requisiti: requisiti:
python3 python3
pip3 install sodapy matplotlib pandas pip3 install sodapy matplotlib pandas tabulate
sintassi: sintassi:

View File

@ -111,6 +111,7 @@ def plot_dataframe(dataframe):
def list_of_csv_files(dir_name): def list_of_csv_files(dir_name):
""" restituisce la lista dei files .zip presenti in una directory """
saved = getcwd() saved = getcwd()
os.chdir(dir_name) os.chdir(dir_name)
filelist = glob.glob('*.zip') filelist = glob.glob('*.zip')
@ -119,6 +120,7 @@ def list_of_csv_files(dir_name):
def parse_range(x): def parse_range(x):
""" espande un range di anni nel formato NNNN-NNNN restituendo una lista dei singoli anni """
x = x.strip() x = x.strip()
if x.isdigit(): if x.isdigit():
yield str(x) yield str(x)
@ -130,6 +132,7 @@ def parse_range(x):
def get_csv_dict(dict): def get_csv_dict(dict):
""" prende un dizionario dei files csv e assegna ad ogni anno un filename e una sigla id, restituendo un dict """
d = {} d = {}
for (k, v) in dict.items(): for (k, v) in dict.items():
filename, id = k, v filename, id = k, v
@ -140,7 +143,7 @@ def get_csv_dict(dict):
elif match_single: elif match_single:
years = [match_single.group()] years = [match_single.group()]
else: else:
print("no match") print("\nError: no match, the filename does not contain any year")
for year in years: for year in years:
d.update({year: [filename, id]}) d.update({year: [filename, id]})
return d return d