Commit 36d2e20c authored by renzo's avatar renzo

fix recover missing data

parent c7cdd0d8
......@@ -14,6 +14,10 @@ def download_shn(tmp_path, date):
if destination_dir and not os.path.exists(destination_dir):
os.makedirs(destination_dir)
destination_path = destination_dir + "/data.csv"
if os.path.exists(destination_path):
return
# Download data from hidro API
ids = ["MDPL", "STER", "SCLE", "OYAR", "ATAL", "LPLA", "PNOR", "BSAS", "SFER"]
names = ['Mar del Plata', 'Santa Teresita', 'San Clemente', 'Oyarvide', 'Atalaya',
......@@ -32,7 +36,7 @@ def download_shn(tmp_path, date):
timestamps = [x["fecha"].split("T")[1][:5] for x in readings[:24]]
# Se escribe el CSV
with open(destination_dir + "/data.csv", 'w') as csvfile:
with open(destination_path, 'w') as csvfile:
writer = csv.writer(csvfile, delimiter=';', dialect='excel')
writer.writerow([""] + len(timestamps) * [datetime.strftime(date, '%d/%m/%Y')])
writer.writerow([""] + len(timestamps) * [datetime.strftime(date, '%d/%m/%Y')])
......
......@@ -16,7 +16,12 @@ def download_all(args):
while (cur_date != max_date):
if (cur_date not in dates):
args["date"] = cur_date
download_and_process(args)
if (args["source"] == "shn" and args["only_download"]):
for day in range(0, 6):
args["date"] = cur_date - timedelta(days=day)
download_and_process(args)
else:
download_and_process(args)
cur_date += timedelta(days=1)
if __name__ == "__main__":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment