Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

39 lines
1.5KB

  1. x <- 1
  2. # I originally dumped everything in data-raw/reports/{sboe_id}/
  3. # but I realized that things will work out best with targets if I can point
  4. # to a single directory for each type of file that needs to be processed.
  5. #
  6. # This script moves the files into the appropriate subdirectories.
  7. #
  8. # {sboe_id}/{report_id}_{received}.txt --> {sboe_id}/all/{report_id}_{received}.txt
  9. # {sboe_id}/{report_id}_{received}_receipts.csv --> {sboe_id}/receipts/{report_id}_{received}_receipts.csv
  10. # {sboe_id}/{report_id}_{received}_expenditures.csv --> {sboe_id}/expenditures/{report_id}_{received}_expenditures.csv
  11. library(fs)
  12. all <- dir_ls(here::here("data-raw", "reports"), glob = "*.txt", recurse = TRUE)
  13. all_new <- path(path_dir(all), "all", path_file(all))
  14. receipts <- dir_ls(here::here("data-raw", "reports"), glob = "*_receipts.csv", recurse = TRUE)
  15. receipts_new <- path(path_dir(receipts), "receipts", path_file(receipts))
  16. expenditures <- dir_ls(here::here("data-raw", "reports"), glob = "*_expenditures.csv", recurse = TRUE)
  17. expenditures_new <- path(path_dir(expenditures), "expenditures", path_file(expenditures))
  18. sboe_dirs <- path_dir(all) |> unique()
  19. cli::cli_progress_step("Moving {.field all}")
  20. dir_create(path(sboe_dirs, "all"))
  21. file_move(all, all_new)
  22. cli::cli_progress_step("Moving {.field receipts}")
  23. dir_create(path(sboe_dirs, "receipts"))
  24. file_move(receipts, receipts_new)
  25. cli::cli_progress_step("Moving {.field expenditures}")
  26. dir_create(path(sboe_dirs, "expenditures"))
  27. file_move(expenditures, expenditures_new)
  28. cli::cli_progress_done()