-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadCSV.py
More file actions
26 lines (20 loc) · 733 Bytes
/
readCSV.py
File metadata and controls
26 lines (20 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#Pgm to read csv file from blob storage
from azure.storage.blob import BlobServiceClient
import pandas as pd
# import tables
STORAGEACCOUNTNAME = <storage_account_name>
# STORAGEACCOUNTKEY= <storage_account_key>
LOCALFILENAME = 'file.csv'
CONTAINERNAME = 'azuretest'
BLOBNAME = 'Sample100.csv'
# download from blob
blob_service = BlobServiceClient(
account_url=<storage_account_url>)
blob_client_instance = blob_service.get_blob_client(
CONTAINERNAME, BLOBNAME, snapshot=None)
with open(LOCALFILENAME, "wb") as my_blob:
blob_data = blob_client_instance.download_blob()
blob_data.readinto(my_blob)
# LOCALFILE is the file path
dataframe_blobdata = pd.read_csv(LOCALFILENAME)
print(dataframe_blobdata.head())