Created
May 26, 2021 03:51
-
-
Save hamelsmu/9fe4eb524001a19e396d28aac2754952 to your computer and use it in GitHub Desktop.
How to upload data to Azure Blob Store
This file contains hidden or 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
import os | |
from azure.storage.blob import BlobServiceClient | |
blob_service_client = BlobServiceClient.from_connection_string(os.getenv('AZURE_STORAGE_CONNECTION_STRING')) | |
with open('gh_repo_topics.parquet', 'rb') as data: | |
blob_client = container_client.upload_blob(name="sample_data/gh_repo_topics.parquet", data=data, overwrite=True) | |
####### Downloading files ########## | |
f = container_client.download_blob("sample_data/gh_repo_topics.parquet") | |
# You can read the file into memory like this | |
hello = f.readall() | |
# Or you can write the file out to disk like this | |
with open("sample_data/gh_repo_topics.parquet", 'wb') as d: | |
f.readinto(d) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment