Forum Discussion
Error when trying to connect the Data Set using Python Script in Power BI
- 2 years ago
Hi All,
i have found the solution for error. i was trying many things. Atlast I went to the C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config and edited the machine.config.
in that file MySql.Data.MySqlClient was there 2 times. I have removed the duplicate and now I am able to run the python script.
Thank you all for the response.Reagrds,
Samith
Hi Samith,
The errors in Power BI might be due to uninitialized objects or missing .NET Framework components. Ensure all objects in your Python script are properly initialized and check for null values. Also, verify that the necessary .NET Framework Data Provider is installed. Updating Power BI and checking dependencies for your Python script and Kaggle API might help. If the issue persists, consider reinstalling the .NET Framework or checking Power BI community forums.
- samithc2 years agoFrequent Visitor
Hi Walter726Herrin ,
Below python script i have tried in VS CODE and it is working in VS CODE.
import kaggleimport osimport pandas as pd# Set Kaggle API credentials directoryos.environ['KAGGLE_CONFIG_DIR'] = 'C:/Users/samit/.kaggle'# Specify the dataset identifierdataset = 'piterfm/paris-2024-olympic-summer-games'# Set the download pathdownload_path = r'D:\SAMITH\Power BI\Paris 2024 Olympics Dashboard\Source'# Remove existing files in the folder to prevent duplicates or outdated filesfor file in os.listdir(download_path):file_path = os.path.join(download_path, file)try:if os.path.isfile(file_path):os.unlink(file_path) # Delete the fileprint(f"Deleted {file_path}")except Exception as e:print(f"Error deleting {file_path}: {e}")# Download the dataset using the Kaggle API and unzip the fileskaggle.api.dataset_download_files(dataset, path=download_path, unzip=True)# List of CSV files to be importedcsv_files = ['athletes.csv','events.csv','medallists.csv','medals.csv','medals_total.csv','schedules.csv','schedules_preliminary.csv','teams.csv','torch_route.csv','venues.csv']# Initialize a dictionary to hold DataFramesdataframes = {}# Iterate through each CSV file and load it into a DataFramefor file in csv_files:# Construct the full path to the CSV filefile_path = os.path.join(download_path, file)# Load the CSV file into a Pandas DataFramedf = pd.read_csv(file_path)# Add the DataFrame to the dictionary using the file name as the keytable_name = file.split('.')[0] # Remove the .csv extensiondataframes[table_name] = dfAlso have tried installing .netframework 8. Not sure how to install .NET Framework Data Provider.Regards,Samith