• R/O
  • SSH

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisioneca957feb5186614e1c95812655e3fc0d1d1f5b9 (tree)
Zeit2024-09-27 02:53:18
AutorLorenzo Isella <lorenzo.isella@gmai...>
CommiterLorenzo Isella

Log Message

Now I input the period and the code automatically retrieves the number of records and the number of pages to download.

Ändern Zusammenfassung

Diff

diff -r e263e2550477 -r eca957feb518 R-codes/spanish_json.R
--- a/R-codes/spanish_json.R Thu Sep 26 14:42:02 2024 +0200
+++ b/R-codes/spanish_json.R Thu Sep 26 19:53:18 2024 +0200
@@ -7,25 +7,60 @@
77
88 source("/home/lorenzo/myprojects-hg/R-codes/stat_lib.R")
99
10+## NB: I have 628,468 records of SA awards for ES in the year 2022
11+
12+
13+ini <- "01/01/2022" ##initial time dd/mm/yyyy
14+fin <- "31/12/2022"
15+
1016 ## url <- "https://www.infosubvenciones.es/bdnstrans/api/ayudasestado/busqueda?page=0&pageSize=10000&order=numeroConvocatoria&direccion=asc&vpd=GE&fechaDesde=01%2F01%2F2019&fechaHasta=31%2F12%2F2022"
1117
18+ini2 <- transform_date_url(ini)
19+fin2 <- transform_date_url(fin)
20+
21+
1222 options(timeout=120)
1323
1424 url1 <- "https://www.infosubvenciones.es/bdnstrans/api/ayudasestado/busqueda?page="
1525
1626
1727
18-url2 <- "&pageSize=10000&order=numeroConvocatoria&direccion=asc&vpd=GE&fechaDesde=01%2F01%2F2019&fechaHasta=31%2F12%2F2022"
28+## url2 <- "&pageSize=10000&order=numeroConvocatoria&direccion=asc&vpd=GE&fechaDesde=01%2F01%2F2022&fechaHasta=31%2F12%2F2022"
29+
30+url2a <- "&pageSize=10000&order=numeroConvocatoria&direccion=asc&vpd=GE&fechaDesde"
31+
32+
33+url2b <- "&fechaHasta"
34+
35+
36+url_for_pages <- paste(url1, 0, url2a, ini2, url2b, fin2, sep="")
37+
38+data_for_pages <- fromJSON(url_for_pages)
39+
40+n_records <- data_for_pages$totalElements
41+
42+print("The total number of records is, ")
43+print(n_records)
44+
45+n_pages <- data_for_pages$totalPages
46+
47+print("and the total number of pages is, ")
48+print(n_pages)
49+
50+saveRDS(n_pages, "../input/number_pages.RDS")
1951
2052 remove_files_with_pattern("../input/data*RDS")
2153
22-for (counter in 0:250){
54+for (counter in 0:(n_pages-1)){
2355
2456 print("counter is, ")
2557 print(counter)
2658
27- url <- paste(url1, counter, url2, sep="")
59+ ## url <- paste(url1, counter, url2, sep="")
2860
61+ url <- paste(url1, counter, url2a, ini2, url2b, fin2, sep="")
62+
63+
2964 mydata <- fromJSON(url)
3065
3166