0
$\begingroup$

I would like to extract the time series from a XML link provided by the ECB. Unfortunately, I am not able to extract the data time series. May someone be able to help me please?

I start to import the data by eurusd=Import["https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange _rates/html/usd.xml", "XML"]

Now I would like to build a time series using the OBS_VALUE out of the XMLElement. Hence I try to extract them by using the command series=eurusd[[All,"OBS_VALUE"]]. Unfortunately this does not work. Can someone please tell me how I can extract the time series out of the XML data link?

Thank you in advance!

Best regards Alex

$\endgroup$
1
$\begingroup$

After correcting your link (removing one blanc) the answer to your question can be found with

Cases[eurusd, ("OBS_VALUE" -> a_) :> a, Infinity]
$\endgroup$
  • $\begingroup$ Dear @UlrichNeumann thank you very the information! It word very well, great! Is it possible to "restrict" the time period (TIME_PERIOD) also? Let's say for one year from 1999-01-04 to 1999-12-30, or do I need to select the elements afterwards? $\endgroup$ – Alexander Hempfing Jan 26 '18 at 14:49
  • $\begingroup$ Sorry I don't know how to select inside Cases. If you pick ob = Cases[eurusd, ("OBS_VALUE" -> a_) :> a, Infinity], ti = Cases[eurusd, ("TIME_PERIOD" -> a_) :> DateList[ a], Infinity] you can combine the elements Transpose[{ob,ti}] and filter data concerning date. $\endgroup$ – Ulrich Neumann Jan 26 '18 at 15:09
  • $\begingroup$ Okay, no worries @UlrichNeumann. Thank you again! $\endgroup$ – Alexander Hempfing Jan 26 '18 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.