Home > Software engineering >  Export multiple dataframes as power bi tables and vice versa
Export multiple dataframes as power bi tables and vice versa

Time:08-04

I am trying to write a python script that will grab multiple different csv files from an input folder, then create a list of dataframes and display them as power bi tables in power bi. The below script is not loading any tables into power bi:

import os
import pandas as pd

path = r'C:\Users\admin\Downloads\Data analysis case study'
csv_files = [os.path.join(path "\\", file) for file in os.listdir(path) if file.endswith('.csv')]

dfs = [pd.read_csv(d) for d in csv_files]

Also, does someone know how to connect this python script to accept a folder path input from a power bi parameter?

CodePudding user response:

There's no need to use Python for this. PowerBI has a "Folder" data source that you can use to combine all the files in a folder into a single Power Query.

enter image description here

CodePudding user response:

Based on this answer, you won't be able to export multiple dataframes to power bi. However, you can merge all your dataframes into one dataframe and import it in power bi, like explained here. I didn't find anything special on exporting data from power bi to python, but you can always export it to a .csv file and import it with pandas.

  • Related