MATLAB Answers

Import data from google sheets to matlab

299 views (last 30 days)
Hüseyin Cagdas Yatkin
Hüseyin Cagdas Yatkin on 12 Dec 2019
Commented: Bennet Den Hoed on 3 Aug 2021
Hello guys,
I wanted to import data from google sheets to matlab. However I couldn't find any information about it. Since the google sheets always geting update I can't just copy and paste so I wanted to import new data for every time I run the matlab script. Is there a way?
Thanks in advance.

Answers (3)

Donald on 4 Mar 2021
First, find the ID for your Sheet. It's the long string if you look at the URL. For example,
http s://
Then it's easy
ID = 'bladjaljd77442n2j3ljk2j3j2jdkdjad'
sheet_name = 'My Sheet';
url_name = sprintf('',...
ID, sheet_name);
sheet_data = webread(url_name);
Bennet Den Hoed
Bennet Den Hoed on 3 Aug 2021
I am finding that any headers that I have in my Google Sheet get included into the "header" of the MATLAB table (unsure of the technical term - see yellow highlight in screenshot). Only the numeric values are included in the MATLAB table itself, making it 4x2 instead of 5x2.
I am actually interested in having the headers included in the table (5x2 case is desirable for me). I've played around a bit, without much luck.
  1. Inserting another row of "dummy headers" in row 1 of the Google Sheet: The two strings get concatenated and left in the "header" of the MATLAB table, still.
  2. Placing the headers at the bottom row of the Google Sheet: These headers are ignored and generic names (Var1, Var2) are instead assigned.
  3. Creating a table of only characters in the Google Sheet: First row is put into the MATLAB "header" and the body of the MATLAB table becomes the other strings.
It seems that the table must be either all numbers or all strings. Again, I would like there to be a mix of this (5x2 case, with the headers as the first row of the MATLAB table).
Can anyone help me figure out how to do this?

Sign in to comment.

Hiro on 12 Dec 2019
  1 Comment
Hüseyin Cagdas Yatkin
Hüseyin Cagdas Yatkin on 12 Dec 2019
I think this is for the offline files, I want to take from online source which is specifically google sheets.

Sign in to comment.

dimuthu chathuranga
dimuthu chathuranga on 9 Apr 2021
I have same problem please help me I want to real time uptade data fron google sheet to mathlab gui

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!