Python Forum
How to read multiple csv files and merge data
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to read multiple csv files and merge data
#1
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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with to check an Input list data with a data read from an external source sacharyya 3 318 Mar-09-2024, 12:33 PM
Last Post: Pedroski55
  Is it possible to extract 1 or 2 bits of data from MS project files? cubangt 8 943 Feb-16-2024, 12:02 AM
Last Post: deanhystad
  python convert multiple files to multiple lists MCL169 6 1,436 Nov-25-2023, 05:31 AM
Last Post: Iqratech
  merge all xlsb files into csv mg24 0 303 Nov-13-2023, 08:25 AM
Last Post: mg24
  splitting file into multiple files by searching for string AlphaInc 2 815 Jul-01-2023, 10:35 PM
Last Post: Pedroski55
  script to calculate data in csv-files ledgreve 0 1,056 May-19-2023, 07:24 AM
Last Post: ledgreve
  Merging multiple csv files with same X,Y,Z in each Auz_Pete 3 1,085 Feb-21-2023, 04:21 AM
Last Post: Auz_Pete
  unittest generates multiple files for each of my test case, how do I change to 1 file zsousa 0 918 Feb-15-2023, 05:34 PM
Last Post: zsousa
  How to read in mulitple files efficiently garynewport 3 845 Jan-27-2023, 10:44 AM
Last Post: DeaD_EyE
  Correctly read a malformed CSV file data klllmmm 2 1,813 Jan-25-2023, 04:12 PM
Last Post: klllmmm

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020