How to Use Google Sheets in Python

  Рет қаралды 71,803

Pretty Printed

Pretty Printed

Күн бұрын

Пікірлер: 188
@meksaldi
@meksaldi 6 жыл бұрын
Well, googling about all technical stuff didn't bring a solution. However, a 15 min. video contains more info than the Google developer site itself. Well done.
@prettyprinted
@prettyprinted 6 жыл бұрын
I'm glad the video helped! Thanks for watching.
@stillinmusic
@stillinmusic 6 жыл бұрын
Same here. Banging my head against the wall when reading Google developer site
@stillinmusic
@stillinmusic 6 жыл бұрын
I was banging my head against the wall when reading google developer site. Thank you so much for saving my head.
@d4lep0ro
@d4lep0ro 6 жыл бұрын
Dude, thank you very much. I was struggling with the incomplete documentation from google and after hours I find a brilliant 15 min solution.
@prettyprinted
@prettyprinted 6 жыл бұрын
Glad it helped. Thanks for watching.
@TheTeachinggeek
@TheTeachinggeek 5 жыл бұрын
Thank you so much! I am a teacher using python in my classroom. Not an expert by any means, but what a boon this skill is now. I have watched a few videos on the topic , but your video gave me the 'aha!' Thank you thank you thank you!
@prettyprinted
@prettyprinted 5 жыл бұрын
I'm glad you like my videos! Thanks for watching
@hfrnd-hu2kz
@hfrnd-hu2kz 6 жыл бұрын
Dude, you are awesome. Clear and concise, can't ask for anything more.
@prettyprinted
@prettyprinted 6 жыл бұрын
Thanks for watching!
@devve7
@devve7 4 жыл бұрын
Excellent explanation, clear, direct, complete. Congratulations, good work !! Regards.
@SilvianDragan
@SilvianDragan 4 жыл бұрын
This is a fantastic video. Literally the template I go to when I need to get started on gsheets manipulation using python.
@kenocontreras
@kenocontreras 6 жыл бұрын
First of all, thank you for your video. Guys, if some of you get an error about "invalid_scope: Empty or missing scope not allowed" I fixed doing this: credentials = ServiceAccountCredentials.from_json_keyfile_name('secret_credentials.json') scope = ['spreadsheets.google.com/feeds', 'www.googleapis.com/auth/drive'] credentials = credentials.create_scoped(scope) gc = gspread.authorize(credentials)
@quaternion-pi
@quaternion-pi 6 жыл бұрын
Excellent! Looking forward to additional videos on using Python with Google Sheets.
@prettyprinted
@prettyprinted 6 жыл бұрын
Thanks for watching!
@eliz4057
@eliz4057 6 жыл бұрын
Thanks sooooooo much! I googled around and read so many documents that didn't really help. Your video is exactly what I need!
@prettyprinted
@prettyprinted 6 жыл бұрын
I'm glad it helped. Thanks for watching.
@larsjohansson1205
@larsjohansson1205 6 жыл бұрын
I do not know python, I just followed the video and it worked, easy peasy. Good tutorial.
@prettyprinted
@prettyprinted 6 жыл бұрын
Glad the video helped. Thanks for watching.
@isaaccoltrain5270
@isaaccoltrain5270 5 жыл бұрын
This was a fantastic tutorial. Please keep making great content like this. Looking forward to checkout out the rest of your channel.
@yuvigerstein
@yuvigerstein 5 жыл бұрын
I'm kind of new to python and to Google APIs, and your tutorial actually worked for me. Awesome work! thank you sir!
@prettyprinted
@prettyprinted 5 жыл бұрын
Glad I could help. Thanks for watching!
@AestheticVodka
@AestheticVodka 6 жыл бұрын
Excellent tutorial, still relevant and super helpful several months down the line, all the best!
@prettyprinted
@prettyprinted 6 жыл бұрын
Thanks for watching!
@auralearningcenterllc5503
@auralearningcenterllc5503 6 жыл бұрын
Very well explained. Excellent Video
@prettyprinted
@prettyprinted 5 жыл бұрын
Glad you think so. Thanks for watching!
@UkiDLucas
@UkiDLucas 6 жыл бұрын
Thank you, I was missing the copy the email and share my own spreadsheet part till now!
@yendys74
@yendys74 5 жыл бұрын
cant thank you enough , this super helpful
@prettyprinted
@prettyprinted 5 жыл бұрын
you're welcome! I'm glad I could help.
@Virusosm
@Virusosm 5 жыл бұрын
At 4:02 What is the thing you pulled up?
@prettyprinted
@prettyprinted 5 жыл бұрын
A terminal for Ubuntu on Windows.
@altafnavalur
@altafnavalur 5 жыл бұрын
Excellent! Thank you so much
@prettyprinted
@prettyprinted 5 жыл бұрын
You're welcome! Thanks for watching.
@brunosantos3672
@brunosantos3672 6 жыл бұрын
I liked, you teach well. Waiting the next.
@prettyprinted
@prettyprinted 6 жыл бұрын
Thanks for watching.
@ArielYLuo
@ArielYLuo 6 жыл бұрын
This is a life saver, thank you!!
@prettyprinted
@prettyprinted 6 жыл бұрын
Glad it helped!
@SolidBuildersInc
@SolidBuildersInc 5 жыл бұрын
Awesome solution. This may be the issue with some other problems I am having with Google Credentials that have been deprecated. Are you still going to provide some examples of this gspread library and the popular Query() Function? This is got me on the edge of my seat.
@SolidBuildersInc
@SolidBuildersInc 5 жыл бұрын
I found it, sorry - kzbin.info/www/bejne/r4G0Y3qhaJiVZ7c
@sharvilpopli4119
@sharvilpopli4119 6 жыл бұрын
very precise, thanks! using gspread for raspberry pi data logging
@prettyprinted
@prettyprinted 6 жыл бұрын
You're welcome! Thanks for watching.
@jaypod
@jaypod 6 жыл бұрын
That's awesome. Thank you so much! It worked. I'm trying to figure out the Google APIs though. Hopefully I'll be able to figure out how to use them instead of the gspread library.
@prettyprinted
@prettyprinted 6 жыл бұрын
I'll probably cover the Google API in the future if they don't keep changing their APIs.
@brandoncavinee4630
@brandoncavinee4630 6 жыл бұрын
Great! Thanks for posting
@prettyprinted
@prettyprinted 6 жыл бұрын
You're welcome. Thanks for watching.
6 жыл бұрын
Nice and handy video. Waint8ng for new lessons
@prettyprinted
@prettyprinted 6 жыл бұрын
Thanks for watching.
@s_p_a_c_e_m_a_n
@s_p_a_c_e_m_a_n 5 жыл бұрын
Awesome video, been trying to figure this out via Goolgle QuickStart and failed, your fixed that! THANK YOU!
@supergogeta283
@supergogeta283 3 жыл бұрын
hello, thank you so much great tutorial! I was wondering if I make a single route flask app to update a google sheet, I want the update to append just by pinging that route, can I do that?
@jhicinternational
@jhicinternational 6 жыл бұрын
Many thanks, God bless you!
@prettyprinted
@prettyprinted 6 жыл бұрын
Thanks for watching!
@LaureanoPiotti9
@LaureanoPiotti9 6 жыл бұрын
Amazing! Thank you very much =)
@prettyprinted
@prettyprinted 6 жыл бұрын
You're welcome! Thanks for watching.
@AntonFrolov1
@AntonFrolov1 6 жыл бұрын
Like a boss, sire. Thank you!
@mohdhasanrizvi6940
@mohdhasanrizvi6940 5 жыл бұрын
you saved us. Thanks
@prettyprinted
@prettyprinted 5 жыл бұрын
Glad I could help.
@slinbody
@slinbody 6 жыл бұрын
Good Tutorial!
@prettyprinted
@prettyprinted 6 жыл бұрын
Thanks!
@bowzer087
@bowzer087 5 жыл бұрын
Do you ever have the error FileNotFoundError: [Errno 2] No such file or directory: 'client_secret.json'? I've followed along to your video but can't get around this error.
@RomuloMagalhaesAutoTOPO
@RomuloMagalhaesAutoTOPO 6 жыл бұрын
Anthony, congratulations! Very simple and clear explanation. But, how I mention before: Do you could use low resolution to record yours video? This will facilite visualization on mobile and tablet. Thank you!
@prettyprinted
@prettyprinted 6 жыл бұрын
It's a tradeoff between videos for desktops and videos for mobile when it comes to code. I prefer desktop because most people will write code along with the videos.
@uppiupenderreddy
@uppiupenderreddy 5 жыл бұрын
Good info, Thank you, how do I create another sheet2 in same doc? Thanks
@prettyprinted
@prettyprinted 5 жыл бұрын
sh.add_worksheet(title="A worksheet", rows="100", cols="20") Here are the docs: github.com/burnash/gspread
@lamissdesdourmettes
@lamissdesdourmettes 6 жыл бұрын
Hello thank you very much for your help! Do you know how to add a formul in a cell and not a string, like add : =A2+B4?
@prettyprinted
@prettyprinted 6 жыл бұрын
Try using value_render_option='FORMULA'. Like this: gspread.readthedocs.io/en/latest/user-guide.html#getting-a-cell-value
@johnson9909
@johnson9909 3 жыл бұрын
I the example.py file the same as manage.py file? I am trying to figure out what file the example.py file is representing and is it meant to be a independent file or is the code supposed to be added to manage.py?
@affankhalid3115
@affankhalid3115 6 жыл бұрын
Thank you for this useful video. I have one question. can I access other sheets which has been created with different google account and share with the Email address I have receive in credential file? if so, can you tell me how?
@gnanke
@gnanke 6 жыл бұрын
You should be able to just add the service account email to the spreadsheet sharing tab that you want to share, then (using the naming convention used in this video) just setup another wks_other var with the new table name in gc.open('')
@xavier_yang
@xavier_yang 6 жыл бұрын
Nice video!
@prettyprinted
@prettyprinted 6 жыл бұрын
Thanks for watching.
@monlewi1976
@monlewi1976 6 жыл бұрын
Cool video. What do you think about overall performance to use google sheets as database for some simple project... even it's easy then include some logics inside google sheets (functions in cells) to achieve more backend functionality, kind of functions i.e. in postgresql. Sounds crazy?
@prettyprinted
@prettyprinted 6 жыл бұрын
Using Google Sheets instead of a database is a good idea if your data is simple enough to be handled by Google Sheets. Can save a lot of time and make it easy for non-programmers to modify your data.
@monlewi1976
@monlewi1976 6 жыл бұрын
Pretty Printed thanks for reply bro
@lukaslindblom
@lukaslindblom 6 жыл бұрын
Great helped a lot! Is there a command for adding all your data at once (not row by row). It seems to take a while...
@prettyprinted
@prettyprinted 6 жыл бұрын
You can use update_cells to handle more than one cell at a time. Check out the API docs: gspread.readthedocs.io/en/latest/
@jsonr
@jsonr 5 жыл бұрын
Hey, great video! Is there a way that I can have it so it runs over and over, because I hear the key expires again after 1 hour. I need to create a refresh key and save it, but I don't know how, and all of the solutions on the docs use google's system, and I don't know all of the information for it.
@pulsepledgelife
@pulsepledgelife 6 жыл бұрын
thank you!
@prettyprinted
@prettyprinted 6 жыл бұрын
You're welcome!
@SuperMaax22
@SuperMaax22 6 жыл бұрын
Hi men, how about the concurrent editing of a cell, is there some kind of tool to disable it ?
@arjunkirpal9776
@arjunkirpal9776 6 жыл бұрын
One word: Awesome
@prettyprinted
@prettyprinted 6 жыл бұрын
Thanks for watching!
@CaptainAdd49
@CaptainAdd49 5 жыл бұрын
How do you get the gspread libraries? When I type that command into cmd or python I get errors.
@kyleyoung4974
@kyleyoung4974 4 жыл бұрын
One thing to add: the file that google provides must be located within the python project folder for this code to work. Most of you probably knew this but...
@mattg5262
@mattg5262 5 жыл бұрын
Can you please make something similar for Google Calendar? Awesome video by the way!
@prettyprinted
@prettyprinted 5 жыл бұрын
I'll consider making one on Google Calendar. Thanks for the idea.
@mattg5262
@mattg5262 5 жыл бұрын
@@prettyprinted Please do!!! There is literally no courses/tutorials how to use it with python !
@RachitKinger
@RachitKinger 6 жыл бұрын
Question - By using this method, I need to add the client_email to the spreadsheet's share settings. Is there a way to get access to all of my drive files and explore them, select the one I need and read from it? By the way - thanks a ton for this tutorial. Was really useful.
@RachitKinger
@RachitKinger 6 жыл бұрын
Sorry about replying to my own question. I figured out a way of doing this and have published a blog post today morning on it in case anyone here is interested - www.wackycoup.com/post/working-with-google-sheets-in-python-pandas-and-r/
@prettyprinted
@prettyprinted 6 жыл бұрын
Thanks for creating the post and linking it here.
@tnebula2100
@tnebula2100 6 жыл бұрын
I'm having a problem installing gspread. I tried to install it with pip (pip install gspread), but then it outputted "-bash: pip: command not found" and when I tried to install pip (Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/bin/apt" (-1)). Using OSX. Can I please have some help???
@johnn4314
@johnn4314 6 жыл бұрын
Thanks decent. but what does installing the Oauth2 client and pyOpen SSL do?
@prettyprinted
@prettyprinted 6 жыл бұрын
OAuth2 (and SSL by extension) allow you to connect to Google's API. It's the way they want you to authenticate.
@breannthiessen5158
@breannthiessen5158 5 жыл бұрын
I have got data going into my sheet1, however I am wondering how to get data into sheet2 in the same document? I tried just putting wks = gc.open('Test').sheet2 that did not work, do I have to make a separate credential? I have been googling solutions and cannot find anything. Thank you!
@dirkb806
@dirkb806 6 жыл бұрын
I assume one can do this setup also in a jupyter notebook? What about an example of automation via a cron hosted somewhere ?
@prettyprinted
@prettyprinted 6 жыл бұрын
Yeah, this can be done in a notebook. I'll think about that example. Thanks for the idea.
@dirkb806
@dirkb806 6 жыл бұрын
Pretty Printed Yeah would be cool to also highlight some automation tools with python!
@Bleeinyourself
@Bleeinyourself 6 жыл бұрын
Thank you so much for this. Question: if I want to hide the "client_secrets.json" file on github and want to use Heroku to hide it as a variable, which key from the JSON file can I pull out to store in place of the "credentials" variable in here: gspread.authorize(credentials)?
@prettyprinted
@prettyprinted 6 жыл бұрын
I'm not completely sure since I haven't done something like that, but the most sensitive value in the json file is the private key.
@Bleeinyourself
@Bleeinyourself 6 жыл бұрын
I think I found the solution. If you don't want to upload the client_secrets.json file on github for everyone to see, you can use a different oauth2client method called "_from_parsed_json_keyfile" which I found in the "\service_account. py". Simply create a variable (in Heroku you can go to config hidden vars to make a hidden variable), and copy/paste the dict-like contents of the "client_secrets.json" and set that as the variable: client_secret = { "type": "service_account", "project_id": ****** ...(rest of the contents of the .json } Then use the "_from_parsed_json_keyfile" method which takes the (dict-like string, scope) as arguments. In your script, set: credentials = ServiceAccountCredentials._from_parsed_json_keyfile(client_secret, scope). Now you shouldn't need to upload the client_secrets.json file publicly. It worked in my IDE and I'm gonna try it with github/heroku.
@prettyprinted
@prettyprinted 6 жыл бұрын
Great! Thanks for sharing this approach.
@pulsepledgelife
@pulsepledgelife 6 жыл бұрын
can I dm you with a question relating to this? working on a similar project, new to python I need the results of my script to dump into the spread sheet
@prettyprinted
@prettyprinted 6 жыл бұрын
You can email me at anthony@prettyprinted.com
@pulsepledgelife
@pulsepledgelife 6 жыл бұрын
Pretty Printed I actually ended up figuring it out, thanks for the reply back tho!
@samapriya1
@samapriya1 6 жыл бұрын
How do you get the list of scopes? or the link to the scope urls?
@prettyprinted
@prettyprinted 6 жыл бұрын
Google has a ton. They'll mention them in the API docs for the API you want to use.
@jamielunn5869
@jamielunn5869 6 жыл бұрын
thanks! when i append a timestamp and a float, the cells in the google sheet are formatted as text. is there a way to append the actual date and float value?
@jamielunn5869
@jamielunn5869 6 жыл бұрын
i got it: wks.append_row([timestamp,value],value_input_option='USER_ENTERED')
@prettyprinted
@prettyprinted 6 жыл бұрын
Glad you figured it out. Thanks for watching!
@keshavdamani1273
@keshavdamani1273 5 жыл бұрын
will there be any problem if that mail of google sheets is not been notified via sheets , is it real mail address ?
@prettyprinted
@prettyprinted 5 жыл бұрын
I'm not sure. Try it out and see if it works.
@ashwinkumarramaswamy9369
@ashwinkumarramaswamy9369 3 жыл бұрын
I don't have that download json option in my console
@LongPham-vg4lz
@LongPham-vg4lz 6 жыл бұрын
Hi, I got this error while following your instruction: ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833). Can you help me ?
@prettyprinted
@prettyprinted 6 жыл бұрын
It could be many things. I've had the same error before. I recommend doing a Google search for the error and trying out the solutions.
@LongPham-vg4lz
@LongPham-vg4lz 6 жыл бұрын
I finally found a solution. But there's another problem. When I use: print(wks.get_all_records), I got this result:
@LongPham-vg4lz
@LongPham-vg4lz 6 жыл бұрын
NVM: I found the mistake. Tks very much man !!!
@shirsendudhar8944
@shirsendudhar8944 4 жыл бұрын
Is there I can make a graph in google sheet from python, and every time I edit the data, the graph auto adjusts accordingly .
@mr_jacklu8014
@mr_jacklu8014 4 жыл бұрын
are you actually asking whether the new data inputted into google sheets via Python codes will automatically update the chart already in Google Sheets? if you have a chart in Google Sheets based on a table with all the columns highlighted and add new rows using Python then the chart should changed based on your edits.
@shirsendudhar8944
@shirsendudhar8944 4 жыл бұрын
@@mr_jacklu8014, yes exactly. I have a dataset in gsheet. Every time I run the python program it is supposed to add a column to the dataset. This thing I want to display in gsheet.
@shubhamgoel238
@shubhamgoel238 4 жыл бұрын
It is showing me error SpreadSheetnotfound. So what should i do now?
@gokulnathgm
@gokulnathgm 6 жыл бұрын
Thanks for the video. Could you please help me resolve this error? oauth2client.client.HttpAccessTokenRefreshError: invalid_scope: spreadsheets.google.com/feeds is not a valid audience string.
@sivaranjan862
@sivaranjan862 6 жыл бұрын
"", I keep getting this message, can someone help me out? Edit: i missed my parenthesis
@nickbissanti
@nickbissanti 6 жыл бұрын
I got this too, did you ever figure this out?
@gabrielbacon8503
@gabrielbacon8503 6 жыл бұрын
How do i get the python stuff
@mattg5262
@mattg5262 5 жыл бұрын
You mean like Python in general?
@ivansim2457
@ivansim2457 6 жыл бұрын
is there a part 2 already?
@prettyprinted
@prettyprinted 6 жыл бұрын
Yes: kzbin.info/www/bejne/r4G0Y3qhaJiVZ7c
@emokhan7927
@emokhan7927 6 жыл бұрын
what is the use or pyopenSSL in this project ? Do I have to do anything special to make SSL request.
@prettyprinted
@prettyprinted 6 жыл бұрын
You need SSL to connect to the API. You don't need to do anything special if your computer is configured correctly. The code in the video should be enough.
@hjain
@hjain 6 жыл бұрын
Is there a way to clone and copy a worksheet from one spreadsheet to another?
@prettyprinted
@prettyprinted 6 жыл бұрын
Look into the copy method: gspread.readthedocs.io/en/latest/api.html#gspread.Client.copy
@noobsauce8952
@noobsauce8952 6 жыл бұрын
Thanks for an incredibly simple and straight forward tutorial, I wish I came here before wasting an hour googling and reading Google Developer docs. One question, do you know how to create a blank Spreadsheet via the gspread API? The gspread docs say this should work: gclient.create("test_this"). It seems to work in the python code (no assertions or errors raised) however nothing is actually created in my Google Sheets account.
@vivekchoudhary8745
@vivekchoudhary8745 6 жыл бұрын
you need to share it too. to make it visible.
@Anya_mjee
@Anya_mjee 6 жыл бұрын
This is very helpful! Is there a way I can write to subsequent sheets "sheet2, sheet3" and so on, when i try specifying 'sheet2', I get the error: wks = gc.open('ec2_tracker').sheet2 AttributeError: 'Spreadsheet' object has no attribute 'sheet2' Other resources online aren't very helpful. Thanks!
@d4lep0ro
@d4lep0ro 6 жыл бұрын
use get_worksheet(index=your_index_number)
@333JaydeeP
@333JaydeeP 5 жыл бұрын
@@d4lep0ro I am also stuck in this point...can you plz elaborate the solution
@yontenjamtsho1539
@yontenjamtsho1539 5 жыл бұрын
I get the error message on my Gmail account "Delivery Status Notification (Failure)". Can you give me a solution to fix it?
@blackmagic10000
@blackmagic10000 6 жыл бұрын
Hello friend. Would it be possible to take a list of URLs from a single column and then scrape a single div of data on each URL and return the values back into the adjacent column? I was able to return a column of Bit.ly links and I am looking to grab the total click amounts. When you take a bit.ly link and append a + to it, it provides the dashboard, which is a whole lot easier than having to go through the login form and deal with the AJAX scroller. Thoughts?
@sourabhkumarsingh1696
@sourabhkumarsingh1696 6 жыл бұрын
i m new to this, can anyone tell me how i can copy & paste the jason file in the directory, i m using Windows 10 & python 3.6 and where i have to run the code of python so it can be run in googlesheet
@IronMan-kb8bl
@IronMan-kb8bl 5 жыл бұрын
how to use search/find in this. eg Say if i gave i/o as 'somedata' it should give the value of neighboring i.e the o/p should be 'someotherdata'.
@MrMaxwell94
@MrMaxwell94 6 жыл бұрын
if anyone was getting an error: feeds is not a valid audience string go to: stackoverflow.com/questions/49829002/invalid-scope-https-spreadsheets-google-com-feeds-is-not-a-valid-audience-str the answer has the updated scope addresses which worked for me
@prettyprinted
@prettyprinted 6 жыл бұрын
Thanks for this!
@ArchAid1
@ArchAid1 6 жыл бұрын
Hi :) Thanks for the great video. I have two questions: 1. How come this video is so different from Google's own documentation (here: developers.google.com/sheets/api/quickstart/python) I mean, your solution obviously works. So I'm just curious. 2. I'm having trouble getting the scope right :-/ Console says: oauth2client.client.HttpAccessTokenRefreshError: invalid_scope: spreadsheets.google.com/feedsgoogleapis.com/auth/drive is not a valid audience string. I've tried to .join() them, but to no avail. Any ideas? Thanks again :D
@prettyprinted
@prettyprinted 6 жыл бұрын
The scopes should be two separate strings in a list. My example is different because it uses the helper library gspread. The tutorial you linked uses Google's own library.
@swist666
@swist666 5 жыл бұрын
There is also a solution called sheetdb.io - it is much easier to setup. You make a request to API and in response you get json data from spreadsheet.
@prettyprinted
@prettyprinted 5 жыл бұрын
I'll check it out. Thanks.
@Jenny-ni3bg
@Jenny-ni3bg 6 жыл бұрын
NICEEEEEEEEEE, LOVE U
@prettyprinted
@prettyprinted 6 жыл бұрын
Thanks for watching.
@mekalabhagyadeepikadeepika524
@mekalabhagyadeepikadeepika524 5 жыл бұрын
how to get credentials file using python code with email and password of gmail account
@archer_biotronica9836
@archer_biotronica9836 5 жыл бұрын
when I share the google sheet file to the client_email: I get a message on my gmail stating that the email provided is invalid. anyone has a solution for this????
@fatmaabdelraouf1134
@fatmaabdelraouf1134 6 жыл бұрын
I got this error message "AttributeError: 'str' object has no attribute 'access_token"
@fatmaabdelraouf1134
@fatmaabdelraouf1134 6 жыл бұрын
I fixed it , thank you for you video it's awsome.
@prettyprinted
@prettyprinted 6 жыл бұрын
You're welcome! Thanks for watching.
@Dudleyism1
@Dudleyism1 6 жыл бұрын
why is the documentation so poor on googles sight or am I that bad ?
@prettyprinted
@prettyprinted 6 жыл бұрын
Google generally makes bad documentation. I guess they know they can get away with it.
@travismiller6818
@travismiller6818 6 жыл бұрын
I am getting the following error requests.exceptions.SSLError: HTTPSConnectionPool(host='sheets.googleapis.com', port=443): Max retries exceeded with url: /v4/spreadsheets/1NqP87YKZFzxs2awftSYT4Uu6BvQTACAUNtxR0_0EhjE?includeGridData=false (Caused by SSLError(SSLError("bad handshake: SysCallError(104, 'ECONNRESET')",),)) It only occures when I try .sheet1 on the .open('FileName') I also get this with .worksheets() and all the others i have found i gspread any help would be appriecated
@prettyprinted
@prettyprinted 6 жыл бұрын
It's hard to say, but it seems to be something with your connection to the API, not the API itself.
@travismiller6818
@travismiller6818 6 жыл бұрын
You were correct seems to be a firewall issue in my school
@RaspberryPieman
@RaspberryPieman 6 жыл бұрын
Hi Anthony - Great Video. I got this working on my Raspberry Pi, straight away using Python3 on Raspbian Stretch, running under user 'pi'. However, I wanted to run it via crontab on reboot. The problem is, that causes it to run under 'root' and then fails with "ImportError: cannot import name 'opentype'". Here is my little example, below. Do you have any idea why this is happening under 'sudo' and how I can fix it? # opentypeProblem.py # run under 'pi' - works OK # pi@raspberrypi:python3 opentypeProblem.py # pi@raspberrypi:done # # run under 'root' (via sudo) - fails # pi@raspberrypi:sudo python3 opentypeProblem.py # Traceback (most recent call last): # File "/home/pi/opentypeProblem.py", line 5, in # from oauth2client.service_account import ServiceAccountCredentials # File "/usr/local/lib/python3.5/dist-packages/oauth2client/service_account.py", line 26, in # from oauth2client import crypt # File "/usr/local/lib/python3.5/dist-packages/oauth2client/crypt.py", line 23, in # from oauth2client import _pure_python_crypt # File "/usr/local/lib/python3.5/dist-packages/oauth2client/_pure_python_crypt.py", line 24, in # from pyasn1_modules.rfc2459 import Certificate # File "/usr/local/lib/python3.5/dist-packages/pyasn1_modules/rfc2459.py", line 20, in # from pyasn1.type import opentype # ImportError: cannot import name 'opentype' import gspread from oauth2client.service_account import ServiceAccountCredentials scope = ['spreadsheets.google.com/feeds', 'www.googleapis.com/auth/drive'] credentials = ServiceAccountCredentials.from_json_keyfile_name('mySpreadsheet.json', scope) gc = gspread.authorize(credentials) wks = gc.open('SampleData').sheet1 name = "Fred" count = 2 wks.append_row([name,count]) print('done')
@prettyprinted
@prettyprinted 6 жыл бұрын
I'm not familiar with the Raspberry Pi, but does your pi user use a virtual environment while your root doesn't?
@RaspberryPieman
@RaspberryPieman 6 жыл бұрын
Hi Anthony, My pi user is not using a virtual environment. However I did a bit more Googling and found others getting similar problems. One post, shows the use of the pip freeze command to show up differences - here is my result: pi@raspberrypi:$ pip3 freeze | grep pyasn1 pyasn1==0.4.4 pyasn1-modules==0.2.2 pi@raspberrypi:$ sudo pip3 freeze | grep pyasn1 pyasn1==0.1.9 pyasn1-modules==0.2.2 It seems that under sudo, the wrong version of pyasn1 is being picked up. I don't know how to fix this though.
@prettyprinted
@prettyprinted 6 жыл бұрын
Could you just update the one used by sudo? So sudo pip install pyasn1 --upgrade
@RyanWebber-videoArtist
@RyanWebber-videoArtist 6 жыл бұрын
raise HttpAccessTokenRefreshError(error_msg, status=resp.status) oauth2client.client.HttpAccessTokenRefreshError: invalid_scope: Empty or missing scope not allowed. can't seem to get past this.
@RyanWebber-videoArtist
@RyanWebber-videoArtist 6 жыл бұрын
got it... I missed the ', scope' in the setting of the credentials. see: gspread.readthedocs.io/en/latest/oauth2.html
@RezicGming
@RezicGming 5 жыл бұрын
God damn, I've been banging my head against the wall at this for the past hour before I realized I was missing the '.com' in 'googleapis.com/auth/drive' ...... Thanks.
@alexmealey8589
@alexmealey8589 6 жыл бұрын
Great Video but I keep getting the same error with my code. Every time I run the code I get "No such file or directory". I've made sure it's the right file name but it still can't get it. Please let me know if anyone has figured this out.
@prettyprinted
@prettyprinted 6 жыл бұрын
Could you give more context for the error message?
@zperk13
@zperk13 6 жыл бұрын
here's the scope list for anyone who wants to copy and paste it scope = ['spreadsheets.google.com/feeds', 'www.googleapis.com/auth/drive']
@serchforvideos
@serchforvideos 5 жыл бұрын
This should be updated.
@rachitkhandelwal5883
@rachitkhandelwal5883 6 жыл бұрын
getting following error can someone help me on this, i am using pycharm and created a file in my package as credential.json, apart from that every thing is same. Traceback (most recent call last): File "C:/Users/training_d5.01.01/PycharmProjects/untitled/GsheetDemo/gsheetexample.py", line 8, in gc = gspread.authorize(credentials) File "C:\Users\training_d5.01.01\PycharmProjects\untitled\venv\lib\site-packages\gspread\__init__.py", line 38, in authorize client.login() File "C:\Users\training_d5.01.01\PycharmProjects\untitled\venv\lib\site-packages\gspread\client.py", line 51, in login self.auth.refresh(http) File "C:\Users\training_d5.01.01\PycharmProjects\untitled\venv\lib\site-packages\oauth2client\client.py", line 545, in refresh self._refresh(http) File "C:\Users\training_d5.01.01\PycharmProjects\untitled\venv\lib\site-packages\oauth2client\client.py", line 749, in _refresh self._do_refresh_request(http) File "C:\Users\training_d5.01.01\PycharmProjects\untitled\venv\lib\site-packages\oauth2client\client.py", line 819, in _do_refresh_request raise HttpAccessTokenRefreshError(error_msg, status=resp.status) oauth2client.client.HttpAccessTokenRefreshError: invalid_scope: spreadsheets.google.com/feeds is not a valid audience string.
@prettyprinted
@prettyprinted 6 жыл бұрын
Are all the packages the latest? Sometimes Google changes things with what's required to use the API.
@EthanGabis
@EthanGabis 5 жыл бұрын
im having the same problem did you manage to fix that?
@johnmcmanus6719
@johnmcmanus6719 6 жыл бұрын
Is that Google API free
@prettyprinted
@prettyprinted 6 жыл бұрын
Yeah within reasonable limits.
@commander_yu_followers
@commander_yu_followers 5 жыл бұрын
This is the real
@Jenny-ni3bg
@Jenny-ni3bg 4 жыл бұрын
arrasooooooooou
@sabecraftgamingandmore1364
@sabecraftgamingandmore1364 5 жыл бұрын
For me, when I print it, it makes multiple dictionaries, one for each row: {{'Organism': 'Reef shark', 'Consumer(s)': 'None', 'Resource(s)': 'Fan worm, Butterfly fish, Angelfish'}} {{'Organism': 'Yeet', 'Consumer(s)': 'yat', 'Resource(s)': 'yoot'}} {{'Organism': 'yat', 'Consumer(s)': 'ying', 'Resource(s)': 'yong'}} I had a button which adds things to the spreadsheet, and the print button updates it. Here is my code: # Imports import gspread from oauth2client.service_account import ServiceAccountCredentials from tkinter import * # Window window = Tk() window.configure(background="black") # Text Box text_box = Text(window, width=50, height=6, wrap=WORD, background="black", foreground="white") text_box.grid(row=0, column=0, sticky=W) # Scope scope = ['www.googleapis.com/auth/drive'] # Credentials credentials = ServiceAccountCredentials. \ from_json_keyfile_name('credentials.json', scope) # Client client = gspread.authorize(credentials) # Sheet sheet = client.open('PaR Energy Flow').sheet1 # Function def printout(): text_box.delete(0.0, END) data = sheet.get_all_records() text_box.insert(END, data) def add_organism(): o = org.get() c = cons.get() r = res.get() sheet.append_row([o, c, r]) org.delete(0, END) cons.delete(0, END) res.delete(0, END) # Button Button(window, text="Print Spreadsheet Data", width=20, command=printout).grid(row=1, column=0, sticky=W) # Text Entries Label(window, width=20, bg="black", fg="white", text="Organism Name: ").grid(row=2, column=0, sticky=W) org = Entry(window, width="20", bg="black", fg="white") org.grid(row=2, column=1, sticky=W) Label(window, width=20, bg="black", fg="white", text="Organism Consumer(s): ").grid(row=3, column=0, sticky=W) cons = Entry(window, width="20", bg="black", fg="white") cons.grid(row=3, column=1, sticky=W) Label(window, width=20, bg="black", fg="white", text="Organism Resource(s): ").grid(row=4, column=0, sticky=W) res = Entry(window, width="20", bg="black", fg="white") res.grid(row=4, column=1, sticky=W) # Button Button(window, text="Add Organism", width=20, command=add_organism).grid(row=5, column=0, sticky=W) # Run mainloop() It would be appreciated if someone could help me. I want it all to be in one list like you have.
@DarickBrokaw
@DarickBrokaw 5 жыл бұрын
“pip is not recognized as an internal or external command” error. I had this error and used the following fix appuals.com/fix-pip-is-not-recognized-as-an-internal-or-external-command/ NOTE: For those extremely new to programming like me this video is done in the Win+R (Run) CMD (Command Line).
Google Sheets - Python API, Read & Write Data
28:01
Learn Google Sheets & Excel Spreadsheets
Рет қаралды 193 М.
How is this Website so fast!?
13:39
Wes Bos
Рет қаралды 1,3 МЛН
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
Using Google Sheets in Python: Finding and Updating Cells
10:24
Pretty Printed
Рет қаралды 30 М.
5 Python Libraries You Should Know in 2025!
22:30
Keith Galli
Рет қаралды 85 М.
💀 R.I.P. YouTube Tutorials: Gemini 2.0 AI is the NEW Teacher
10:00
Teacher's Tech
Рет қаралды 100 М.
Always Check for the Hidden API when Web Scraping
11:50
John Watson Rooney
Рет қаралды 658 М.
Google Sheets API Automation in Python
26:36
NeuralNine
Рет қаралды 98 М.
5 Excel Secrets You'll Be Embarrassed You Didn't Know
17:32
Excel Campus - Jon
Рет қаралды 282 М.
Python Tutorial: Web Scraping with BeautifulSoup and Requests
45:48
Corey Schafer
Рет қаралды 1,1 МЛН
Top 18 Most Useful Python Modules
10:50
Tech With Tim
Рет қаралды 936 М.
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН