Consider the PISA study report, which contains dozens separate spreadsheets in each respective excel files (see http://www.oecd.org/pisa/keyfindings/pisa-2012-results-volume-iv.htm) Is there any way to call on a particular spreadsheet when one import the material?
-
$\begingroup$ Welcome to Mathematica.SE, please consider taking the tour. Your question may be put on-hold because it is a duplicate and it has already been answered. Please at least edit your question to improve it. Particularly, include a minimum example of the code you are working on. $\endgroup$– rhermansSep 19, 2014 at 9:11
1 Answer
Assuming the XLS
file is in this URL:
url = "http://statlinks.oecdcode.org/982013061P1T001.XLS";
This gives you the list of sheets in the XLS
file
sheetslist = Import[url, {"XLS", "Sheets"}];
And you can Import
the second sheet by
Import[url, {"Sheets", sheetslist[[2]]}]
Backtracking, now to get that URL...
Get a list of links in the page:
urlHome="http://www.oecd.org/pisa/keyfindings/pisa-2012-results-volume-iv.htm";
linklist=Import[urlHome, "Hyperlinks"];
Select
only the ones that point to doi.org as those are the XLS
files
urldoi = Select[linklist, StringMatchQ[#, "http://dx.doi.org" ~~ __] &]
You can confirm that by fetching the URL headers
headers = URLFetch[#, "Headers"] & /@ urldoi ;
headers[[All, 3, 2]]
{"http://statlinks.oecdcode.org/982013061P1T001.XLS", \ "http://statlinks.oecdcode.org/982013061P1T002.XLS", \ "http://statlinks.oecdcode.org/982013061P1T003.XLS", \ "http://statlinks.oecdcode.org/982013061P1T004.XLS", \ "http://statlinks.oecdcode.org/982013061P1G001.XLS", \ "http://statlinks.oecdcode.org/982013061P1T005.XLS", \ "http://statlinks.oecdcode.org/982013061P1T006.XLS", \ "http://statlinks.oecdcode.org/982013061P1G002.XLS", \ "http://statlinks.oecdcode.org/982013061P1T007.XLS", \ "http://statlinks.oecdcode.org/982013061P1G003.XLS", \ "http://statlinks.oecdcode.org/982013061P1G003.XLS", \ "http://statlinks.oecdcode.org/982013061P1T008.XLS", \ "http://statlinks.oecdcode.org/982013061P1G004.XLS", \ "http://statlinks.oecdcode.org/982013041P1T010.XLS", \ "http://statlinks.oecdcode.org/982013041P1T011.XLS", \ "http://statlinks.oecdcode.org/982013061P1T010.XLS", \ "http://statlinks.oecdcode.org/982013061P1T009.XLS"}