I would like to create a dict. which would include several csv files, each file having a year as a name. All files are in a folder. As far as I can see, each has the same number of columns, and the separator is comma. Unfortunately, my code is not working and I can't figure out why. I have tried to add engine , sep, delimiter, header.. nothing fixed the problem. In the end,I also would like to make one big DataFrame from these files without losing any information. Can someone help me to solve the problem? Thanks.
I have the following code:
df_dict = {}
for dirname, _, filenames in os.walk(' used my path the the folder'):
for filename in filenames:
print(os.path.join(dirname, filename))
df_filename = pd.read_csv(os.path.join(dirname, filename), engine='python' )
df_filename['Year'] = filename[:-4]
df_dict[filename[:-4]] = df_filename
The error message: "ParserError: Expected 1 fields in line 4, saw 2"