I'm reading multiple csv files in from a folder. While reading multiple files I receive UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 21: invalid start byte
When I try to read file one-by-one I provide encoding of type - "ISO-8859-1"
in pandas.read_csv(file_name, encoding
). My final objective is to append all files in single data frame. Following is the code I'm using for the mentioned purpose.
import glob
files = glob.glob('/path_name/*.csv')
df = None
for i, f in enumerate (files):
if i == 0:
df = pd.read_csv(f)
df['fname'] = f
else:
tmp = read_csv(f)
tmp['fname'] = f
df = df.append(tmp)
df.head()