I am trying to import only a specific range of a Google spreadsheet as data in Mathematica for further usage like plotting. So I tried to use the
data = Import["https://...", "Data"] function, but get as a result everything in the spreadsheet, including the impressum. In the documentation I found the article about "Import a spreadsheet" for .xls, but when I try to specify the range via
data = Import["https://..." ,{"Data", 1, Table[i, {i, 3, 12}], {1, 2, 3}}]
I get the error message "Import: The import element "3" is not present when importing as HTML." So is it possible to import only some columns and rows out of my Google spreadsheet or do I have to download it as .xls?

  • $\begingroup$ Can you provide a working URL for sample data for others to explore this problem? $\endgroup$ – Mr.Wizard Dec 19 '18 at 21:04
  • 1
    $\begingroup$ Yes of course, so from this spreadsheet: docs.google.com/spreadsheets/d/… I want to import the second column and the third column in the rows 1 to 10 $\endgroup$ – A.S. Dec 19 '18 at 21:59
  • $\begingroup$ Is it useful to you to read the CSV file without manually downloading it, like this? Import["https://docs.google.com/spreadsheets/d/1RHCJZGJ58EmDAVQgepODBPgfMW-\ 5WfzcJOSa9Gn_bDE/export?format=csv&id=1RHCJZGJ58EmDAVQgepODBPgfMW-5WfzcJOSa9Gn_bDE&\ gid=0", {"Data", Range[3, 9], {1, 2, 3}}] $\endgroup$ – Mr.Wizard Dec 20 '18 at 1:24
  • $\begingroup$ Yes, I just don't want to download every sheet every time manually, when me or other persons are updating the table. But actually when I copy this in my notebook (without the backslashes and gaps), I get the same error message as before: "The Import element "3" is not present when importing as HTML", even if the export format should be CSV? $\endgroup$ – A.S. Dec 20 '18 at 7:14
  • $\begingroup$ It looks like the CSV link in my comment above expired. Please try this attempt that does not require CSV export: Import["https://docs.google.com/spreadsheets/d/1RHCJZGJ58EmDAVQgepODBPgfMW-\ 5WfzcJOSa9Gn_bDE/edit#gid=0", {"HTML", "Data", 1, 2, Range[3, 9], Range[2, 5]}] – For me this gives output {{"1,9", "0,701", "11,53", "0,005"}, {"2,6", "0,722", "17,86", "0,005"}, {3, "0,732", "21,90", "0,005"}, {"3,3", "0,739", "25,32", "0,005"}, {4, "0,751", "32,60", "0,005"}, {"4,7", "0,760", "38,30", "0,005"}, {"5,4", "0,768", "45,10", "0,005"}} $\endgroup$ – Mr.Wizard Dec 20 '18 at 9:22

Your Answer

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

Browse other questions tagged or ask your own question.