From 49cd6144413c0fc66d5d759facd4e5e33464a135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Alonso=20=C3=81lvarez?= Date: Wed, 20 Dec 2023 17:50:23 +0000 Subject: [PATCH] Modify functions to use timezone --- importing/functions.py | 4 +--- importing/views.py | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/importing/functions.py b/importing/functions.py index 83220c89..709094f5 100755 --- a/importing/functions.py +++ b/importing/functions.py @@ -93,7 +93,7 @@ def get_last_uploaded_date(station_id, var_code): return datetime -def preformat_matrix(source_file, file_format): +def preformat_matrix(source_file, file_format, timezone: str): """ First step for importing data. Works out what sort of file is being read and adds standardised columns for date and datetime (str). This is used in construct_matrix. @@ -152,7 +152,6 @@ def preformat_matrix(source_file, file_format): skipfooter=skipfooter, engine=engine, encoding="ISO-8859-1", - error_bad_lines=False, ) else: file = pd.read_csv( @@ -164,7 +163,6 @@ def preformat_matrix(source_file, file_format): skipfooter=skipfooter, engine=engine, encoding="ISO-8859-1", - error_bad_lines=False, ) datetime_format = file_format.date.code + " " + file_format.time.code diff --git a/importing/views.py b/importing/views.py index efa1c293..8257c2db 100755 --- a/importing/views.py +++ b/importing/views.py @@ -18,7 +18,9 @@ import os import shutil import urllib +from logging import getLogger +import pandas as pd from django.contrib.auth.decorators import permission_required from django.http import HttpResponse, JsonResponse from rest_framework import generics @@ -58,6 +60,8 @@ class DataImportTempCreate(generics.CreateAPIView): def perform_create(self, serializer): file = copy.deepcopy(self.request.FILES["file"]) + timezone = serializer.validated_data["station"].timezone + getLogger().warning(timezone) matrix = preformat_matrix(file, serializer.validated_data["format"]) del file # Set start and end date based on cleaned data from the file