Google Colab is the most widely used Python Notebook to quickly test your Python code snippets, if you have a use case where you want to upload a certain file say .csv, .json, or .txt, and wondering how to upload it so you can use it, then you can make use of files from google.colab module,
Example:from google.colab import files
uploaded = files.upload()
Choose File: sample-json-file.txt
(text/plain) - 358 bytes, last modified: n/a - 100% done
Saving sample-json-file.txt to sample-json-file.txt
When you execute this code snippet you will get the option to upload a file,
Now you can read the file and use it the way you want in your code!
import json
json_file = open("sample-json-file.txt", "r")
json_str = json_file.read()
json_obj = json.loads(json_str)
for element in json_obj:
print(element['name'])
print(element['age'])
print(element['city'])
print("-----------")
More Posts related to Google,
- How to upload and read csv file in Google Colab
- Resolving DNS_PROBE_FINISHED_NXDOMAIN Google Chrome Error
- Fix - ModuleNotFoundError: No module named google.colab
- Fetch More then 10 Links Per Page in Google Search Result
- Find Nearest Gas Station using Google Map App on your Phone
- How to get nest aware on iPhone
- Fix: Cannot contact reCAPTCHA. Check your connection and try again.
- Enable Dark Mode in Google Search
- How to Mount Google Drive in Colab Notebook
- [Fix] reCAPTCHA not working in Web Browser
- Google Celebrates Rosa Bonheur 200th birthday with a Google Doodle
- How to Subscribe to Google Nest Aware on iPhone
- Google Local Guide Program and Perks of Contributing to Google Maps
- How to remove disable google search blue triangle
- 86 Gmail keyboard shortcuts that you may find Advantageous
- How to insert image into Google Sheets cell
- How to Open a New Notebook in Google Colab
- Google Colab: How to read file from Google Drive
- How to Access Local Files in Google Colab
- Installing Google Cloud macOS SDK
- Turning Off Chat in Gmail
- How to do a Reverse Image Search Using Google Tools
- Google Search Console: HTTPS is invalid and might prevent it from being indexed
- How to Show Line Numbers in Google Colab Cells
- Fetch as Google Crawl Error or Redirected Status
More Posts:
- Ignore white space while Notepad++ compare two files - NotepadPlusPlus
- Bash Command to Base64 Decode a String - Bash
- Install Cygwin on Windows PC to learn Objective-C - Objective-C
- Split a String in Java with Examples - Java
- Fix - You're missing out! Ask your admin to enable Microsoft Teams - Teams
- Fix: SyntaxError: The requested module does not provide an export named default - JavaScript
- Java: Generate random numbers within a range - Java
- Import Other Python Files Examples - Python