使用python代码一次将多个数据框加载到Power BI

时间:2019-10-07 11:31:41

标签: python powerbi

我无法使用“获取数据”中的python代码选项一次将所有数据帧加载到Power BI中,而单独选择数据帧确实可以将它们加载到Power BI中。

我已经使用python代码创建了4个数据帧,并且在Power BI“获取数据”中使用代码时,数据帧确实显示了,但是我无法一次全部将它们全部加载到Power BI中。但是,如果我单独选择df,则可以在Power BI中成功加载它们。

这是我在Power BI中遇到的错误

Load
Count_By_Stat4_df
Load was cancelled by an error in loading a previous table.
Count_By_Stat3_df
Load was cancelled by an error in loading a previous table.
Count_By_Stat2_df
ADO.NET: Python script error.
 Traceback (most recent call last):
 File "PythonScriptWrapper.PY", line 27, in <module>
 s3.download_file(bucket_name, Product_Metrics_s3_path, Product_Metrics_local_path)
 File "C:\python\lib\site-packages\boto3\s3\inject.py", line 172, in download_file
 extra_args=ExtraArgs, callback=Callback)
 File "C:\python\lib\site-packages\boto3\s3\transfer.py", line 307, in download_file
 future.result()
 File "C:\python\lib\site-packages\s3transfer\futures.py", line 106, in result
 return self._coordinator.result()
 File "C:\python\lib\site-packages\s3transfer\futures.py", line 265, in result
 raise self._exception
 File "C:\python\lib\site-packages\s3transfer\tasks.py", line 126, in __call__
 return self._execute_main(kwargs)
 File "C:\python\lib\site-packages\s3transfer\tasks.py", line 150, in _execute_main
 return_value = self._main(**kwargs)
 File "C:\python\lib\site-packages\s3transfer\download.py", line 603, in _main
 osutil.rename_file(fileobj.name, final_filename)
 File "C:\python\lib\site-packages\s3transfer\utils.py", line 271, in rename_file
 rename_file(current_filename, new_filename)
 File "C:\python\lib\site-packages\s3transfer\compat.py", line 25, in rename_file
 os.remove(new_filename)
 PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\pbi\\Product_Metrics.xlsx'
Counts_By_Stat1_df
Load was cancelled by an error in loading a previous table.
test_metrics_df
Load was cancelled by an error in loading a previous table.
Close
    for file in glob.glob('*AddressFabric_Product_Metrics.xlsx'):
        Counts_By_Stat1_df = pd.read_excel(file, 'Sheet1')
        Counts_By_Stat2_df = pd.read_excel(file, 'Sheet2')
        Counts_By_Stat3_df = pd.read_excel(file, 'Sheet3')
        Counts_By_Stat4_df = pd.read_excel(file, 'Sheet4')

0 个答案:

没有答案