Python Forum

Full Version: How to read multiple csv files and merge data
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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)