Created
January 1, 2019 11:37
-
-
Save IJEMIN/195f1492d76d491f9154b399a391b956 to your computer and use it in GitHub Desktop.
Download Google Play Console Sales Report from google cloud storage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.cloud import storage | |
import os | |
certificationJsonFile = 'XXXXX.json' | |
bucketName = r'pubsite_prod_rev_XXXXXX' | |
reportYear = 2018 | |
# Connecte with Service Account | |
storage_client = storage.Client.from_service_account_json(certificationJsonFile) | |
# Get Bucket contain sales data | |
bucket = storage_client.get_bucket(bucketName) | |
# Get blobs contain 'sales' prefix | |
prefix = 'sales' | |
blobs = bucket.list_blobs(prefix=prefix) | |
if not os.path.isdir(prefix): | |
os.mkdir(prefix) | |
for blob in blobs: | |
if str(reportYear) in blob.name: | |
blob.download_to_filename(r'./' + blob.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment