<aside> 🔐 **[Mini-course Alert]** Before diving into your work on Google Cloud, take some time to learn about security on GCP. This essential mini-course covers everything you need to know about managing access, implementing permissions, and ensuring your resources are secure. You'll learn about Identity and Access Management (IAM), the Principle of Least Privilege, and practical steps to safeguard your GCP environment. Strengthen your security skills now to protect your projects effectively!
</aside>
<aside> 🔥 [Mini-Course Alert] If this is your first time working with Cloud Storage or simply want to refresh your knowledge, we've designed a free mini-course for you. This comprehensive course covers all the essentials. [TIP] You can also use this course as a reference when dealing with Cloud Storage.
</aside>
Following our exploration of Google Cloud Platform basics and creating our first cloud project, we dive into the practical application of these tools. In this chapter, we focus on storing raw data—the unprocessed information retrieved directly from the Weather API. This data, typically in JSON format, includes detailed current and forecasted weather metrics like temperature, humidity, and wind speed, which we initially handle in its native, nested JSON structure. Our objective is to store this raw data in Google Cloud Storage effectively.
Prerequisites:
pip install google-cloud-storage pyarrow
We also, need to create a Service Account (with roles: ”Storage Admin”, “Storage Folder Admin”, and “Storage Object Admin”) so that we can store data from our local machine to Cloud Storage. If you haven’t done it yet, read the corresponding chapter.
📌 Note: I renamed the service account file to "cloud-storage-admin-service-account.json" and placed it in the same directory as the main.py Python script.
Preparing the code:
At the top of your main.py file, right after importing the requests and pandas libraries, import the following packages:
File: main.py
import os
from google.cloud import storage
import datetime
import json