-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgeneral-info-fixes.R
More file actions
27 lines (22 loc) 路 902 Bytes
/
Copy pathgeneral-info-fixes.R
File metadata and controls
27 lines (22 loc) 路 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
library(tidyverse)
infos <- dir("data-output",
pattern = "info",
full.names = TRUE)
infosname <- basename(infos)
the_csv <- infos[1:2] |>
purrr::map(readr::read_csv) |>
purrr::map2(.y = str_replace_all(infosname[1:2],
"_general.+csv$",
""),
\(x = .x, y = .y) dplyr::mutate(x, lang_name = y))
the_tsv <- infos[3:length(infos)] |>
purrr::map(readr::read_tsv) |>
purrr::map2(.y = str_replace_all(infosname[3:length(infos)],
"_general.+csv$",
""),
\(x = .x, y = .y) dplyr::mutate(x, lang_name = y)) |>
purrr::map(~mutate(.x, query = replace_na(query, "--")))
the_infos <- c(the_csv, the_tsv)
purrr::walk2(the_infos,
infos,
\(df, filename) write_csv(df, filename))