Python Forum
How to read multiple csv files and merge data - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to read multiple csv files and merge data (/thread-25371.html)



How to read multiple csv files and merge data - rajeshE - Mar-28-2020

Hi,
I have two csv files,
csv1:
c1 c2 c3 c4 c5
BB 2  5  6  O
csv2:
c7 c8 c9 c10 c11
C  0  2  0  L
I want to read both files(ignore headers), and merge data:
desired output:
BB 2 5 6 O
C 0 2 0 L
I use below code,
but they are not merging properly.
final_df=[]
for filename in fList:
    df = pd.read_csv(filename, index_col=None, header=0)
    print(df)
    print("--"*12)
    final_df.append(df)
df_concat = pd.concat(final_df, axis=0, ignore_index=True)