Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am newer using Mathematica to plot with the Function: CountryData, I am trying to plot "OilReserves" in "UnitedKingdom" from 1985 until 2014. I don't know how to do it, please help me!

share|improve this question
CountryData["UnitedArabEmirates", {"OilReserves", 1995}] returns "CountryData::notprop: {"OilReserves", 1995} is not a known property for CountryData. Use CountryData["Properties"] for a list of properties. >>" yet CountryData["UnitedArabEmirates", {"OilReserves"}] returns {Quantity[9.78*10^10, "Barrels"]}. This suggests that "OilReserves" is not an historic datum. However I may be attempting to request the data incorrectly. – Mr.Wizard Aug 8 '14 at 5:30

Download the data (csv file) from U.S. Energy Information Administration;

data = Import[

ListLinePlot[data[[5 ;; -6]],
 Frame -> True,
 Axes -> False,
 PlotRange -> All,
 PlotLabel ->
  StringReplace[data[[1, 1]],
   "1980" -> "1985"],
 FrameLabel -> data[[5]]]

enter image description here

share|improve this answer
Nice way to get it done. How did you get a CSV file? I see a "Download Excel" link but that gives an XLS file. – Mr.Wizard Aug 8 '14 at 7:14
On linked page under Overview data for United Kingdom, click Petroleum. Scroll to Proved Reserves and click on thumbnail of chart. On displayed chart, click on menu symbol and selected Download Data. Download is a csv file. – Bob Hanlon Aug 8 '14 at 7:22
Thanks for helping me! – Arturo Ortiz Aug 13 '14 at 5:35

Have you tried this link? It lets you select the country and date range. After the table is displayed, I just selected the values I wanted (highlighted yellow in the picture below), and paste it to MMA using ImportString to let MMA parse it.

Mathematica graphics

pasted = ImportString["paste it here"];
Short[pasted, 5]

Mathematica graphics

Then I did some processing to remove the {, , , ..} you saw in the pasted string, and also to replace any NA value with the value of the previous year. I also transformed the data to the right format for plotting:

processed = Drop[pasted, {2}] /. {a___, x_, "NA", b___} :> {a, x, x, b};
pointPairs = Transpose[{processed[[1]], #1}] & /@ Rest[processed];
Short[pointPairs, 5]

Mathematica graphics

Plotting yearly values of North America oil reserves (sidenote: what's that jump for Canada after 2002 about?)

ListLinePlot[Rest /@ pointPairs, PlotLegends -> pointPairs[[All, 1, 2]]]

Mathematica graphics

share|improve this answer
@ seismatica - Canada's oil sands resources were deemed to be technically and economically recoverable in 2003. (ref.) – Chris Degnen Aug 8 '14 at 8:07
Thanks @ChrisDegnen! Will read that in the morning as that sounds very interesting. – seismatica Aug 8 '14 at 8:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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