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
  python to read the data from oracle melinda 3 1,580 Aug-18-2025, 10:24 AM
Last Post: Larz60+
  Merge htm files with shutil library (TypeError: 'module' object is not callable) Melcu54 7 4,815 Mar-09-2025, 04:25 PM
Last Post: Pedroski55
  I'm trying to merge 2 .csv files with no joy! Sick_Stigma 3 1,596 Aug-03-2024, 03:20 PM
Last Post: mariadsouza362
  Trying to generating multiple json files using python script dzgn989 4 4,474 May-10-2024, 03:09 PM
Last Post: deanhystad
  Help with to check an Input list data with a data read from an external source sacharyya 3 2,615 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 6,214 Feb-16-2024, 12:02 AM
Last Post: deanhystad
  python convert multiple files to multiple lists MCL169 6 4,522 Nov-25-2023, 05:31 AM
Last Post: Iqratech
  merge all xlsb files into csv mg24 0 1,133 Nov-13-2023, 08:25 AM
Last Post: mg24
  splitting file into multiple files by searching for string AlphaInc 2 4,149 Jul-01-2023, 10:35 PM
Last Post: Pedroski55
  script to calculate data in csv-files ledgreve 0 3,251 May-19-2023, 07:24 AM
Last Post: ledgreve

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.