Hi, in this video, we're going to load a Google spreadsheet in Python.
More specifically, we're going to get to the data and bring them out here on the terminal.
And we're going to do that using pandas.
But in this video, we're going to work on a public Google Sheet, which means the sheets can be accessed
by anyone who has a link of the spreadsheet.
Then in the next videos, we're going to go even further and do the same, but with private spreadsheets
which are invite only.
So the owner of the sheets has to give access to someone using an email address to the person who is
invited.
And then we can update spreadsheets, delete, add, delta and so on.
So for this lecture, we're going to keep it simple and work on a public sheet.
So that's installed pandas.
If you're following this, triple pandas is probably installed for you, so you don't need to do that.
So this is more about letting you know that we need the pandas library to do this.
And more specifically, we need the pandas that read see as the methods, which expects usually a C
as we file local file.
But you can also give to this a URL pointing to a C as V file.
So.
Here I have a spreadsheet on my Google account.
So you should have yours if you don't, you have a link to this public spreadsheet in the lecture resources.
And I'm going to use that link now here in the lead.
See, as we methods to get the public link to a spreadsheet, you should go to your spreadsheet and
go to share of and down here.
But if all this could be restricted to, only two people added.
But if you want to give access to anyone, you want to click here to change to anyone with a link.
And then.
Make sure this is selected.
Anyone with the link and then copy link done and then go to Python.
Create some quotes to make a string.
Or even better, just create a variable variable URL is equal to a string.
So that is a long string, but it's not complete, we have to change something from there.
So viewers will go here, but let's change something from this URL.
So we have the main part of the URL.
We have slash d and then we have video of the sheet.
Now we remove that last part.
We leave the slash and then we write G the i z slash t q question mark t que x equals to alt c as v.
And Sheet equal to 2013.
And that is equal to the dots we see as video URL print.
That's all.
And let's see what we get.
Yeah.
These are the dots on.
So what I just did is I loaded the first sheet 2013, so with this method, you can only load individual
sheets.
But of course, you can load any sheet that you want.
And let's say this was you were you were Elf four sheet one and then you create another Euro four sheets
to equal to that.
So it's the same string.
But guess what?
Well, the last part here is not 2013, but is the name of the next sheet 2014 that you see down here.
So this one has some other dots on.
You see the year changes of these data and so on.
So that means we would have different data frames.
Dots on one four URL sheets one.
Dota two for Earth sheets to answer one.
And then print them out.
Respectively.
So let me explain you what these dots are.
You see these columns.
So we have here month the horror and these other ones are some empty columns.
So they go up to call them 25.
If you wanted to fix that, so you would have to go to the spreadsheet and delete all these columns,
the empty ones.
So select them up to that.
And then right click and go to delete columns g to that.
I'll do that for the other sheet.
This will delete or run again, and this time we have some more clear data.
So that is the most recent output.
That's one here for 2013.
These for 2014.
That's a complete script.
So that was hard to load Delta from a public spreadsheet to know with pandas, it's not possible to
write, to change a spreadsheet, to be able to edit spreadsheets, you need to use the Google Sheets
API and we're going to do that in the next video.
So I'll see you there.