Skip to content

Commit 80c1907

Browse files
committed
improve the archiving, curated the functions to those being used.
1 parent ebc13e3 commit 80c1907

5 files changed

+140
-171082
lines changed

00_source_me.R

+15-12
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@
1313
#' TO DO before sourcing this file:
1414
#'
1515
#' Get an RTRA account. (application form in directory `SAS`, send to Naomi)
16-
#' upload the 2 .SAS files in directory `SAS` to https://www75.statcan.gc.ca/eft-tef/en/operations (To StatCan).
16+
#' upload the 4 .SAS files in directory `SAS` to https://www75.statcan.gc.ca/eft-tef/en/operations (To StatCan).
1717
#' grab a coffee...
18-
#' download the 2 resulting csv files (From StatCan) and place in directory "data/current".
18+
#' download the 4 resulting csv files (From StatCan) and place in directory "data/current".
1919
#' Click the Git button and pull to make sure the script is the most recent version.
2020
#' then source this file.
2121

22-
#' Note that Jan 2026 the SAS files will need to be updated.
23-
#' 1. The .csv files starting with `dont_delete` will need to be deleted.
24-
#' 2. December's .csv files will need to be copied from old inputs to current inputs and prepended with `dont_delete`.
25-
#' 3. the SAS files will need to be updated regarding the dates.
22+
#' Note that Jan 2026 new sas files will be needed.
2623

2724
#' Output found in directory out/current.
2825

@@ -40,7 +37,7 @@ assertthat::assert_that(length(list.files(here::here("data","current"), pattern=
4037
msg="2 files with the pattern ftptemp4digNAICS must be in folder data/current")
4138
assertthat::assert_that(length(list.files(here::here("data","current"), pattern="lfsstat4digNAICS"))==2,
4239
msg="2 files with the pattern lfsstat4digNAICS must be in folder data/current")
43-
assertthat::assert_that(length(list.files(here::here("data"), pattern="mapping.xlsx"))==1,
40+
assertthat::assert_that(length(list.files(here::here("data"), pattern="industry_mapping"))==1,
4441
msg="The file mapping.xlsx must be in folder data")
4542
assertthat::assert_that(length(list.files(here::here("data"), pattern="template"))==1,
4643
msg="The file template.xlsx must be in folder data")
@@ -55,11 +52,17 @@ rmarkdown::render("02_dashboard.Rmd",
5552
output_dir = here::here("out","current"))
5653

5754

58-
#archive input files--------
59-
# filesstrings::file.move(here::here("data","current", list.files(here::here("data", "current"), pattern = "RTRA")),
60-
# here::here("data", "old"), overwrite = TRUE)
61-
#
62-
#
55+
#replace random prefix on input files with today's date, then archive--------
56+
57+
tibble(wrong_names=list.files(here::here("data", "current"), pattern = "RTRA"))|>
58+
mutate(correct_names=sub("^[^_]+", today(), wrong_names))|>
59+
mutate(correction=map2(wrong_names, correct_names, file.rename.wrapper))
60+
61+
filesstrings::file.move(here::here("data",
62+
"current",
63+
list.files(here::here("data", "current"),
64+
pattern = as.character(today()))),
65+
here::here("data", "old"), overwrite = TRUE)
6366

6467

6568

0 commit comments

Comments
 (0)