I have some folders at the location : log_files_path. All these folders contain CSVs with different names. My aim is to read all these csvs from all the folders present at log_files_path and collate them into a single dataframe. I wrote the following code :
all_files = pd.DataFrame()
for region in listdir(log_files_path):
region_log_filepath = join(log_files_path, region)
#files stores file paths
files = [join(region_log_filepath, file) for file in listdir(region_log_filepath) if isfile(join(region_log_filepath, file))]
#appends data from all files to a single a DF all_files
for file in files :
all_files = all_files.append(pd.read_csv(file, encoding= 'utf-8')).reset_index(drop=True)
return all_files
This gives me an error : UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 61033: invalid start byte
On opening the CSVs, found out that some columns have values like :
and ƒÂ‚‚ÃÂÂÂ.
I want to ignore such characters all together. How can I do it?