Sep 05 2017
- last edited on
Jul 12 2019
I've been able to create a storage account, then a container, than a blob storing a .csv file. I've successfully been able to download the .csv file from Azure itself and using Python as well via the azure-storage package. This is to confirm that external sources (i.e. Python) are able to import/export blobs. The .csv stores a numeric table with header in the first row.
The second step is to import the same data in Excel 2016. The steps that I'm following from Excel are:
New Query --> From Azure --> From Microsoft Azure Blob Storage --> provide <Account_name> and <Key> --> Navigator. From here, I can see that dataset.csv file in the container.
However, clicking the button "load" in the Navigator only allows to download the table in the previous picture in excel, and not the data stored in those files.
I've explored the add ons "Design" and "Query" to look for a button to download the data stored in those blobs but unsuccessfully.
Question: how to import the numberic data stored in one of the .csv in Azure Blobs listed in the Wizard?
Sep 05 2017 01:23 PMSolution
Hi, don't load the connection, edit the connection
then in the Power Query screen, filter the 'Name' column to get the files you want, then click on the column 'Content' to actual get the data.
Sorry my example sheets have only one column, but you can use the Power Query features to transform the files.
Mar 20 2021 08:27 AM
Mar 20 2021 08:33 AM
Mar 20 2021 08:51 AM
Mar 20 2021 09:40 AM
Dec 26 2022 06:04 AM
To read a CSV file stored in Azure Blob Storage from Excel in Python, you can use the azure-storage-blob library and the pandas library.
Here's an example of how you can do it:
# Import the necessary libraries from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient import pandas as pd # Get the connection string for your storage account # Replace `<your_storage_account_name>` and `<your_storage_account_key>` with your storage account name and key connection_string = "DefaultEndpointsProtocol=https;AccountName=<your_storage_account_name>;AccountKey=<your_storage_account_key>;EndpointSuffix=core.windows.net" # Create a BlobServiceClient using the connection string blob_service_client = BlobServiceClient.from_connection_string(connection_string) # Get the container client for the container where your CSV file is stored # Replace `<your_container_name>` with the name of your container container_client = ContainerClient.from_connection_string(connection_string, container_name="<your_container_name>") # Get the blob client for the CSV file # Replace `<your_csv_file_name>` with the name of your CSV file blob_client = BlobClient.from_connection_string(connection_string, container_name="<your_container_name>", blob_name="<your_csv_file_name>.csv") # Download the CSV file from Azure Blob Storage csv_stream = blob_client.download_blob() # Read the CSV file into a pandas DataFrame df = pd.read_csv(csv_stream) # Now you can work with the data in the DataFrame print(df)
This code will connect to your storage account, download the CSV file from the specified container and blob, and read the contents of the CSV file into a pandas DataFrame. You can then work with the data in the DataFrame as needed.
I hope this helps!