diff --git a/cloud-functions/python/functions/performance/main.py b/cloud-functions/python/functions/performance/main.py index e83663e..00ec514 100644 --- a/cloud-functions/python/functions/performance/main.py +++ b/cloud-functions/python/functions/performance/main.py @@ -56,7 +56,32 @@ def performance(request): else: start_date = "2023-12-04" end_date = "2023-12-05" - + + if 'file' not in request.files: + print('No file part') + + file = request.files['file'] + + if file.filename == '': + print('No selected file') + + # Save the file to a temporary location + temp_filepath = '/tmp/temp_file.csv' + file.save(temp_filepath) + + # Load the file into a Pandas DataFrame + try: + df_reference_device_raw = pd.read_csv(temp_filepath) # Adjust the read method based on your file type (e.g., read_excel for Excel files) + # Now you can work with the DataFrame (e.g., perform analysis or display it) + print(df_reference_device_raw.head()) + print('File uploaded and loaded into DataFrame successfully') + except Exception as e: + print(f'Error loading the file: {str(e)}') + finally: + # Remove the temporary file + os.remove(temp_filepath) + + path_delim = "/" db = firestore.client()