Skip to content

issues #316 and #317#324

Merged
pitkant merged 3 commits into
rOpenGov:v4.1-devfrom
ake123:v4.1-dev
Sep 8, 2025
Merged

issues #316 and #317#324
pitkant merged 3 commits into
rOpenGov:v4.1-devfrom
ake123:v4.1-dev

Conversation

@ake123

@ake123 ake123 commented Jul 7, 2025

Copy link
Copy Markdown
Contributor

issues #316 and #317
created one function to do all the downloads from the links provided from data browser download:

  • Tab separated values (.tsv)
  • SDMX-CSV 1.0 (.csv)
  • SDMX-CSV 2.0 (.csv)
  • SDMX-ML 2.1 StructureSpecific (.xml)
  • SDMX-ML 2.1 Generic (.xml)
  • SDMX-ML 3.0 (.xml)
  • JSON-stat (.json)

@pitkant

pitkant commented Jul 7, 2025

Copy link
Copy Markdown
Member

Thanks, will test this shortly and provide feedback if needed.

@pitkant

pitkant commented Jul 8, 2025

Copy link
Copy Markdown
Member

I tested this with the link https://ec.europa.eu/eurostat/api/dissemination/sdmx/2.1/data/ttr00011/A.T.FRM_LD_NLD.TOT.TOTAL.EU27_2020+EA20+EA19+BE+BG+CZ+DK+DE+EE+IE+EL+ES+FR+HR+IT+CY+LV+LT+LU+HU+MT+NL+AT+PL+PT+RO+SI+SK+FI+SE+IS+LI+NO+CH+UK+BA+ME+MK+AL+RS+TR?format=TSV&compressed=true&startPeriod=2013&endPeriod=2024

  1. It would be good if the function used httr2 instead of httr
  2. It would be great if the function utilized existing eurostat package functions. Now the output is pretty rough, as it doesn't parse the missing value : correctly and it does not interpret the first column of the tsv correctly and unpack the variables before year columns:
head(testi)
# A tibble: 6 × 13
  `freq,unit,tra_meas,schedule,tra_cov,geo\\TIME_PERIOD` `2013`      `2014`       `2015`       `2016`      `2017`      `2018`      `2019`      `2020`      `2021`      `2022`      `2023`      `2024`     
  <chr>                                                  <chr>       <chr>        <chr>        <chr>       <chr>       <chr>       <chr>       <chr>       <chr>       <chr>       <chr>       <chr>      
1 A,T,FRM_LD_NLD,TOT,TOTAL,AT                            "196459 "   "217785 "    "216621 "    "223421.2 " "227642.8 " "237700.6 " "228223.4 " "165013.2 " "194820.2 " "188182.2 " "190293.5 " "227789.7 "
2 A,T,FRM_LD_NLD,TOT,TOTAL,BA                            ": "        ": "         ": "         ": "        ": "        ": "        ": "        ": "        "11518.7 "  "16195 "    "17709 "    ": "       
3 A,T,FRM_LD_NLD,TOT,TOTAL,BE                            "957012.2 " "1014585.6 " "1126234.1 " "1088734 "  "1251173 "  "1416428 "  "1397513 "  "1584640 "  "2083632 "  "1729332 "  "1519106 "  "1714273 " 
4 A,T,FRM_LD_NLD,TOT,TOTAL,BG                            "19574.9 "  "23072.8 "   "31520 "     "32976.9 "  "34806.7 "  "29867.3 "  "28748.6 "  "25844 "    "25686 "    "26457 "    "21957.3 "  "22481.2 " 
5 A,T,FRM_LD_NLD,TOT,TOTAL,CH                            "400028.4 " "407703.6 "  "401924.6 "  "428495.5 " "486164.2 " "493201.9 " "459877 "   "272379.7 " "341402.7 " "364304.6 " "359146.6 " "411705.9 "
6 A,T,FRM_LD_NLD,TOT,TOTAL,CY                            "28327.9 "  "28095 "     "27626.2 "   "28430 "    "30880.4 "  "32186.1 "  "32360.1 "  "24006.6 "  "25149.5 "  "25141.9 "  "26702.4 "  "31851.4 " 

Comment thread R/get_eurostat_link.R Outdated
resp <- httr::GET(link)
httr::stop_for_status(resp)
raw <- httr::content(resp, as = "raw")
if (httr::http_type(resp) == "application/gzip" || grepl("compress=true", link, ignore.case = TRUE)) {

@pitkant pitkant Jul 8, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pitkant

pitkant commented Jul 8, 2025

Copy link
Copy Markdown
Member

The issue with "compress=true" on row 28 is still not resolved with commit ea5d4c9.

@pitkant

pitkant commented Jul 9, 2025

Copy link
Copy Markdown
Member

Ah, yes, you're right that the SDMX 2.1 and SDMX 3.0 API logic seems to be different. 3.0 will probably be the future but I think it makes sense to support 2.1 as well.

Ok, I looked at the API urls provided by the data browser and indeed it seems that all download links - even the SDMX-ML 2.1 StructureSpecific (.xml) and SDMX-ML 2.1 Generic (.xml) point to 3.0 endpoint and then add &formatVersion=2.1 at the end. Weird but if it works it works. Seems like prioritising support for 3.0 conventions is the way to go, the syntax to adding filters seems to also be more flexible than with 2.1.

@pitkant
pitkant merged commit 1d95026 into rOpenGov:v4.1-dev Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants