From 115c6976f94f3acb21ea2e364515b1bc94d95e8b Mon Sep 17 00:00:00 2001 From: richard beer <richard.beer@uk-halle.de> Date: Wed, 29 May 2024 13:46:12 +0200 Subject: [PATCH] =?UTF-8?q?Erarbeitung=20um=20das=20validfrom=20tag=20f?= =?UTF-8?q?=C3=BCr=20den=20EmailVersand=20zu=20setzen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- function_load.R | 64 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/function_load.R b/function_load.R index 4216818..7fac15c 100644 --- a/function_load.R +++ b/function_load.R @@ -30,7 +30,67 @@ if (length(commandArgs(trailingOnly = TRUE)) > 0) { #create global variable for the readline-command choice <- T - +function_create_validfrom <- function(combinedDataFrame){ + #nrow(cleaned_df) + # Format für validfrom + # 2023-10-23 08:02 + + #erhöht den Tag immer um 1, damit das Skript ab dem nächsten Tag startet. + date <- paste(year(Sys.time()),,,sep="-") + zyear <- year(Sys.time()) + zmonth <- month(Sys.time()) + zday <- day(Sys.time())+1 + list_for_hour <- c() + + for (i in 0:23){ + if(i<10){ + list_for_hour <- c(list_for_hour,paste0(zyear,"-",zmonth,"-",zday," ","0",i,":00")) + } else{ + list_for_hour <- c(list_for_hour,paste0(zyear,"-",zmonth,"-",zday," ",i,":00")) + } + } + print(list_for_hour) + + # es werden 300-500 Mails in einer Stunde versendet. + # bei 24h werden somit zwischen 7200 und 12000 Mails versendet. + # bei 100.000 werten und 7200 Mails muss ich also über 14 Tage gehen. + + # Erstelle einen leeren Vektor für die Datumswerte + date_values <- c() + + # Schleife von 0 bis 23 Stunden + for (i in 0:23) { + # Erhöhe das Datum um eine Stunde + current_date <- start_date + hours(i) + + # Füge das Datum zum Vektor hinzu + date_values <- c(date_values, current_date) + + # Wenn die Stunde 23 ist, erhöhe den Tag um eins und setze die Stunde auf 0 + if (i == 23) { + start_date <- start_date + days(1) # Erhöhe den Tag um eins + start_date <- start_date - hours(23) # Setze die Stunde auf 0 + } + } + + + anzahl_zeilen <- nrow(cleaned_df) + + # Schleife über die Anzahl der Zeilen + for (i in 1:anzahl_zeilen) { + # Schreibe den aktuellen Wert in die Spalte 'column_name' + cleaned_df$validfrom[i] <- date + + # Aktualisiere den Wert nach jeweils 300 Zyklen + if (i %% 300 == 0) { + date <- wert + 1 + } + } + + + + combined_token_with_download +} #first: define all functions: @@ -338,4 +398,4 @@ function_end <- function(){ function_read_prompt() #dont use quit() -> it restarts your R-Studio } -} \ No newline at end of file +} -- GitLab