Ceridan

Untitled

Jan 15th, 2021 (edited)
702
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pyarrow.parquet as pq
  2. from azure.storage.blob import BlobServiceClient
  3.  
  4.  
  5. blob_service_client = BlobServiceClient.from_connection_string("<Azure Blob Storage Connection String>")
  6. container_client = blob_service_client.get_container_client("export")
  7.  
  8. # List blobs
  9. blobs_list = container_client.list_blobs()
  10. for blob in blobs_list:
  11.     print(blob.name + '\n')
  12.  
  13. # Download single blob
  14. blob_client = container_client.get_blob_client("<Path to particular file>")
  15. with open("sample.parquet", "wb") as f:
  16.     download_stream = blob_client.download_blob()
  17.     f.write(download_stream.readall())
  18.  
  19. # Display sample
  20. sample = pq.read_table("sample.parquet")
  21. print(sample.to_pandas())
  22.  
RAW Paste Data