Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to read and write file (like txt or json) with Colab and Google Drive #865

Closed
jasonhargrove opened this issue Nov 18, 2019 · 1 comment

Comments

@jasonhargrove
Copy link

jasonhargrove commented Nov 18, 2019

How to read and write file (like txt or json) to Google Drive. This issue is for documentation purposes (Google struggles to answer this and took some trial and error).

from google.colab import drive
drive.mount('/content/drive')
# open existing text file
with open('/content/drive/My Drive/Sandbox/Sandbox.txt’) as f:
  print(f.read())
# make new JSON file
with open('/content/drive/My Drive/Sandbox/Sandbox_2.json', 'w') as f:
  f.write('{"hello":true}')
@jasonhargrove jasonhargrove changed the title How to read and write file (like txt or json) to Google Drive How to read and write file (like txt or json) with Colab and Google Drive Nov 18, 2019
@aryehlev
Copy link

helpfull, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants