Right now I'm creating a program which combines csv files into one with like columns not duplicated. The columns created would need to be added next the the adjacent column.
As of right now I'm able to get the files but I'm unable to determine a way to develop a way to iterate a data frame over each read csv and then merge all of these data frames together and push out a csv file. RIght now I'm testing out this with three csv files with a common ID column What I have right now is as follows:
os.chdir(filedname)
data = pd.merge([pd.DataFrame.from_csv(file) for
file in glob.glob("*.csv")],on='ID')
data.to_csv('merged.csv')
The files look like this:
(File 1) (File 2)
ID BLA ID X
1 2 1 55
2 3 2 2
3 4 3 12
4 5 4 52
And each different column besides the ID column in each csv file in the directory should be merged with each other to create one csv file like this:
ID BLA X
1 2 55
2 3 2
3 4 12
4 5 52
Any advice would be great in helping me solve this problem.