13
13
# ' TO DO before sourcing this file:
14
14
# '
15
15
# ' 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).
17
17
# ' 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".
19
19
# ' Click the Git button and pull to make sure the script is the most recent version.
20
20
# ' then source this file.
21
21
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.
26
23
27
24
# ' Output found in directory out/current.
28
25
@@ -40,7 +37,7 @@ assertthat::assert_that(length(list.files(here::here("data","current"), pattern=
40
37
msg = " 2 files with the pattern ftptemp4digNAICS must be in folder data/current" )
41
38
assertthat :: assert_that(length(list.files(here :: here(" data" ," current" ), pattern = " lfsstat4digNAICS" ))== 2 ,
42
39
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 ,
44
41
msg = " The file mapping.xlsx must be in folder data" )
45
42
assertthat :: assert_that(length(list.files(here :: here(" data" ), pattern = " template" ))== 1 ,
46
43
msg = " The file template.xlsx must be in folder data" )
@@ -55,11 +52,17 @@ rmarkdown::render("02_dashboard.Rmd",
55
52
output_dir = here :: here(" out" ," current" ))
56
53
57
54
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 )
63
66
64
67
65
68
0 commit comments