I'm looking to read in multiple CSV files from the same directory and store them into separate pandas dfs. The CSVs don't have the same column headings. The code successfully lists all of the csv files in the directory but it errors when I run the rest. Here is my code currently:
import pandas as pd
import os
import glob
path = "/file/path/"
all_files = glob.glob(os.path.join(path, "*.csv"))
for file in all_files:
file_name = os.path.splitext(os.path.basename(file))[0]
dfn = pd.read_csv(file)
dfn.index.name = file_name
I get the error message "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa3 in position 137: invalid start byte".