I have the below code checks for a file in a location stored under variable loads. Given below is the code that does that:
if type == 'file_1':
current_directory = path.abspath(path.join(__file__, ".."))
base = os.path.join(current_directory, 'file')
loads = pd.read_csv(base + f'/output/{name}_{date}.csv', sep= ',')
resp = make_response(loads.to_csv(index=False))
resp.headers["Content-Disposition"] = f'attachment; filename={name}_{date}.csv'
resp.headers["Content-Type"] = "text/csv"
return resp
I am trying to have this modified such that if file check if the file exists in loads, it returns the csv file else return an empty Dataframe. Could anyone assist how could I modify this, Thanks