Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eurostat API broken #251

Closed
minemR opened this issue Feb 1, 2023 · 10 comments · Fixed by #253
Closed

eurostat API broken #251

minemR opened this issue Feb 1, 2023 · 10 comments · Fixed by #253
Assignees

Comments

@minemR
Copy link

minemR commented Feb 1, 2023

It seems that Eurostat has turned off previous API?

> inw <- get_eurostat("prc_hicp_inw",
+                     filters = list(
+                       coicop = v,
+                       geo = "EA",
+                       sinceTimePeriod = "1996"),
+                     time_format = "date_last"
+                     , cache = F
+                     )
Error in get_eurostat_json(id, filters, type = type, stringsAsFactors = stringsAsFactors,  : 
  The requested url cannot be found within the get_eurostat_json function: http://ec.europa.eu/eurostat/wdds/rest/data/v2.1/json/en/prc_hicp_inw?coicop=CP00&coicop=FOOD&coicop=FOOD_P&coicop=FOOD_NP&coicop=IGD_NNRG&coicop=NRG&coicop=SERV&geo=EA&sinceTimePeriod=1996
In addition: Warning message:
In is.null(filters) || filters != "none" :
  'length(x) = 3 > 1' in coercion to 'logical(1)'

But bulk download still works:

inw_new <- get_eurostat("prc_hicp_inw",
                        time_format = "date_last", cache = F)
@lz1nwm
Copy link

lz1nwm commented Feb 7, 2023

Thank you for the fix! I just want to report a bug in eurotime2date():

> get_eurostat('une_rt_m', filters = list(geo='EA19', s_adj='SA', sex='T', unit='PC_ACT', age='TOTAL'),
+              time_format = "date_last", cache = F)
# A tibble: 481 x 8
   freq  s_adj age   unit   sex   geo   time    values
   <chr> <chr> <chr> <chr>  <chr> <chr> <fct>    <dbl>
 1 M     SA    TOTAL PC_ACT T     EA19  1983-01     NA
 2 M     SA    TOTAL PC_ACT T     EA19  1983-02     NA
 3 M     SA    TOTAL PC_ACT T     EA19  1983-03     NA
 4 M     SA    TOTAL PC_ACT T     EA19  1983-04     NA
 5 M     SA    TOTAL PC_ACT T     EA19  1983-05     NA
 6 M     SA    TOTAL PC_ACT T     EA19  1983-06     NA
 7 M     SA    TOTAL PC_ACT T     EA19  1983-07     NA
 8 M     SA    TOTAL PC_ACT T     EA19  1983-08     NA
 9 M     SA    TOTAL PC_ACT T     EA19  1983-09     NA
10 M     SA    TOTAL PC_ACT T     EA19  1983-10     NA
# ... with 471 more rows
# i Use `print(n = ...)` to see more rows
Warning message:
In eurotime2date(x, last = TRUE) :
  Unknown time code, -. No date conversion was made.

            Please fill bug report at https://github.com/rOpenGov/eurostat/issues.

@antagomir
Copy link
Member

Many thanks. We aim to look at this as soon as situation allows. Meanwhile, PR:s welcome, too, as always.

@pitkant
Copy link
Member

pitkant commented Feb 7, 2023

Thank you! I overlooked that data downloaded through JSON API calls get processed by the same convert_time_col -> eurotime2date function chain as data downloaded from bulk download facilities. I will produce a fix to this later this day as I am anyway currently working on #243 (Transitioning from Eurostat Bulk Download to API)

@lz1nwm
Copy link

lz1nwm commented Mar 6, 2023

I see new version on cran 3.8.2, but the issue mentioned above is still not fixed.

@antagomir antagomir reopened this Mar 6, 2023
@antagomir
Copy link
Member

Thanks for pointing out. We are having a look asap.

pitkant added a commit that referenced this issue Mar 7, 2023
pitkant added a commit that referenced this issue Mar 7, 2023
@pitkant
Copy link
Member

pitkant commented Mar 7, 2023

I see new version on cran 3.8.2, but the issue mentioned above is still not fixed.

Thanks, I was skimming through the issues and noticed unfortunately only now that there was the issue of date handling here. It is now fixed in my PR but unfortunately not in the CRAN version. I think we will make a new CRAN release when the old bulk download facilities are deprecated so the issue will be permanently fixed there, but in the mean time I recommend using the dev version from GitHub / r-universe.

@lz1nwm
Copy link

lz1nwm commented Mar 7, 2023

Thanks for the quick response @pitkant! Cold you fix it for quarters as well?

get_eurostat('namq_10_gdp', filters = list(unit = list('CON_PPCH_PRE'), s_adj = list('SCA'), na_item = list('B1GQ')), time_format = "date_last")

@pitkant
Copy link
Member

pitkant commented Mar 7, 2023

I think it should already work as intended for quarters as well. Here's my printout (eurostat 3.8.3 from https://github.com/rOpenGov/eurostat/tree/pitkant-4 branch):

> get_eurostat('namq_10_gdp', filters = list(unit = list('CON_PPCH_PRE'), s_adj = list('SCA'), na_item = list('B1GQ')), time_format = "date_last")
Table namq_10_gdp cached at /var/folders/f4/h_r3y60n0nn0qm6qx5hnx1s00000gn/T//RtmpVxrL4J/eurostat/namq_10_gdp_date_last_code_FF.rds
# A tibble: 8,640 × 7
   freq  unit         s_adj na_item geo       time       values
   <chr> <chr>        <chr> <chr>   <chr>     <date>      <dbl>
 1 Q     CON_PPCH_PRE SCA   B1GQ    EU27_2020 1975-03-31     NA
 2 Q     CON_PPCH_PRE SCA   B1GQ    EU27_2020 1975-06-30     NA
 3 Q     CON_PPCH_PRE SCA   B1GQ    EU27_2020 1975-09-30     NA
 4 Q     CON_PPCH_PRE SCA   B1GQ    EU27_2020 1975-12-31     NA
 5 Q     CON_PPCH_PRE SCA   B1GQ    EU27_2020 1976-03-31     NA
 6 Q     CON_PPCH_PRE SCA   B1GQ    EU27_2020 1976-06-30     NA
 7 Q     CON_PPCH_PRE SCA   B1GQ    EU27_2020 1976-09-30     NA
 8 Q     CON_PPCH_PRE SCA   B1GQ    EU27_2020 1976-12-31     NA
 9 Q     CON_PPCH_PRE SCA   B1GQ    EU27_2020 1977-03-31     NA
10 Q     CON_PPCH_PRE SCA   B1GQ    EU27_2020 1977-06-30     NA
# … with 8,630 more rows
# ℹ Use `print(n = ...)` to see more rows

@lz1nwm
Copy link

lz1nwm commented Mar 7, 2023

I had to restart my session and now the date is ok. Thanks again!

pitkant added a commit that referenced this issue Mar 7, 2023
@pitkant pitkant linked a pull request Aug 11, 2023 that will close this issue
@pitkant
Copy link
Member

pitkant commented Dec 20, 2023

Permanent fix to the described issue is now in a stable release of eurostat package version 4.0.0. Closing this issue with the CRAN release of package version 4.0.0

@pitkant pitkant closed this as completed Dec 20, 2023
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 a pull request may close this issue.

4 participants