How can I merger multiple .CSV files with same column names but each file has different dates?

Viewed 16

I have n-numbers of .CVS files of stocks profit loss data. Each .CVS file contains two columns - Symbols and P&l. I want to make a master .CVS file where one column will be Symbols and then n- numbers of columns with P&l data having column name as the file name i.e. dates. like..... Symbol, 20.09.22, 21,09.22, 22.09.22

1 Answers
  1. Make an initial (empty) dataframe
  2. Make a list of all n .csv files
  3. Import them using a for loop and merge them with the initial dataframe, make sure that you merge on Symbol and that the new column name is the name of the used .csv file. Note that for the first dataframe you do not need to merge as there is nothing to merge with.

Good luck!

Related