I have the following code which displays the csv files present in the folder of Azure file share
from azure.storage.file import FileService
file_service = FileService(account_name='storage_account_name', account_key='key')
generator = file_service.list_directories_and_files('path/../..')
for file_or_dir in generator:
print(file_or_dir.name)
However, I want to store the csv files in a pandas dataframe and do further operations. Can anyone please help me how to access the csv files and add them in dataframe
After reproducing from my end, I could able to read the csv files using pd.read_csv(< FileName >)
. Below is the complete code that worked for me.
from azure.storage.file import FileService
import pandas as pd
file_service = FileService(account_name='<ACCOUNT_NAME>', account_key='<ACCOUNT_KEY>')
generator = file_service.list_directories_and_files('fileshare/')
for file_or_dir in generator:
print(file_or_dir.name)
getfile=file_service.get_file_to_path(share_name='fileshare',directory_name='',file_path=file_or_dir.name,file_name=file_or_dir.name)
df=pd.read_csv(file_or_dir.name)
print(df)
RESULTS:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.