Merging Csv columns from multiple files into 1 master file | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Merging Csv columns from multiple files into 1 master file

I need serious help in merging columns of multiple CSV files into 1 master CSV file. These CSV files have 1 common column. Any kind of help is highly appreciated 🙏🙏🙏 Thank you 😌

27th Oct 2021, 7:25 PM
Sunil Dhasmana
3 Answers
+ 4
First read each csv into a dataframe. import pandas as pd df1 =pd.read_csv(filepath) ... After mastercsv = pd.concat( (iDF.set_index('name') for iDF in [df1, df2, df3]), axis=1, join='inner' ).reset_index() Finally save as csv. mastercsv.to_csv(path)
27th Oct 2021, 8:12 PM
Oma Falk
Oma Falk - avatar
+ 3
Easily with pandas Check how to read csv and how to join them.
27th Oct 2021, 7:57 PM
Oma Falk
Oma Falk - avatar
0
Yes I've tried. Would you like to invest your time in helping me out?
27th Oct 2021, 8:05 PM
Sunil Dhasmana