0

我正在尝试使用 Python 将数据帧上传到 Azure Notebooks 中 Azure Datalake Gen2 中容器中的目录,但出现错误。

下面是我的代码:

list=['Category','Product']
for i in list:
print(i)
def Append_file_azure(i):
    all_data = []
    for file in container_client.list_blobs('EIM/Sales/Test/' + i):
        if ".csv" in file.name:
            print(file.name)
            file_link = requests.get(importLocation + file.name).content
            dataframe_append = pd.read_csv(io.StringIO(file_link.decode('utf-8')), sep = ",", parse_dates= ["SystemModstamp"])
            all_data.append(dataframe_append)

    result = pd.concat(all_data)
    file_table_duplicate_Remove = result[result.groupby("Id")["SystemModstamp"].transform("max") == result["SystemModstamp"]].drop_duplicates()
    Master_file = file_table_duplicate_Remove.groupby('Id',as_index=False,sort=False).last()

    return Master_file

i = Append_file_azure(i)

from azure.storage.blob.aio import BlobClient

blob = BlobClient.from_connection_string(connection_string, container_name="infatest", blob_name="my_blob")

with open(i, "rb") as data:
    blob.upload_blob(data)

以下是错误:

Category
EIM/Sales/Test/Category/2020/12/02/Category__c_20201202084532.csv
EIM/Sales/Test/Category/2021/07/02/Category__c_20210702084532.csv
EIM/Sales/Test/Category/2021/09/01/Category__c_20210901105016.csv
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-36-1804fe634925> in <module>
     21 
     22     blob = BlobClient.from_connection_string(connection_string, container_name="infatest", blob_name="my_blob")
---> 23     with open(i, "rb") as data:
     24         blob.upload_blob(data)
     25 

TypeError: expected str, bytes or os.PathLike object, not DataFrame
4

0 回答 0