-
Notifications
You must be signed in to change notification settings - Fork 0
/
leer-todo-2022-09-26.qmd
69 lines (50 loc) · 1.07 KB
/
leer-todo-2022-09-26.qmd
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
title: "Leer todo"
format: html
editor: visual
---
## Objetivo
- Escribir el codigo necesario para traer y analizar las imagenes en el google-drive
## Inicio
```{r}
#librerias necesarios
library(googledrive)
library(magick)
library(tidyverse)
root_path <- "SubPublicidades"
```
```{r}
my_root <- drive_ls(root_path)
str(my_root)
```
```{r}
my_root
```
## Extraer subcarpetas de las lineas
```{r}
my_data <- data.frame()
for(i in 1:nrow(my_root)){
tmp <- drive_ls(my_root[i,])
for(j in 1:nrow(tmp)){
tmp2 <- drive_ls(tmp[j,])
my_data <- my_data %>%
bind_rows(data.frame(
Linea = my_root[[i,'name']],
periodo = tmp[[j,'name']],
image_name = tmp2$name,
id_image = tmp2$id))
}
}
my_data
```
### Bajar los archivos y guardarlos localmente
```{r}
my_data$filename <- paste0(my_data$Linea,"_",my_data$periodo,"_",my_data$image_name)
dir.create("tmp")
for(i in 1:nrow(my_data)){
drive_download(as_id(my_data$id_image[i]), path = paste0("tmp/",my_data$filename[i]))
}
```
```{r}
write_rds(my_data, "./tmp/file_info.rds")
```