Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas merge csv files
#3
(Dec-16-2019, 10:01 AM)Axel_Erfurt Wrote: Are the separators commas?

Whatever.
You could put them together as strings.

file1 = "/path/file1.csv"
file2 = "/path/file2.csv"
outfile = "/path/all_together.csv"
all_together = ""

with open(file1, 'r') as f:
    all_together = f.read()
    
with open(file2, 'r') as f:
    all_together = f"{all_together}{f.read()}"

with open(outfile, 'w') as f:
    f.write(all_together)

yes they are commas! ok I would try your solution.
Reply


Messages In This Thread
Pandas merge csv files - by karlito - Dec-16-2019, 09:17 AM
RE: Pandas merge csv files - by Axel_Erfurt - Dec-16-2019, 10:01 AM
RE: Pandas merge csv files - by karlito - Dec-16-2019, 10:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Import multiple CSV files into pandas Krayna 0 1,714 May-20-2021, 04:56 PM
Last Post: Krayna
  Python - Pandas writing blank files to file tdunphy 0 1,990 Jan-14-2021, 12:11 AM
Last Post: tdunphy
  Creating many csv files from Pandas EMA 0 1,624 Jul-26-2020, 06:39 PM
Last Post: EMA
  Pandas merge question smw10c 2 5,705 Jul-02-2020, 06:56 PM
Last Post: hussainmujtaba
  Python pandas merge with or conditional Lafayette 0 2,169 May-07-2020, 07:34 PM
Last Post: Lafayette
  Pandas dataframe merge snmmat 1 2,116 Mar-09-2020, 06:56 PM
Last Post: jefsummers
  Need Help With Filtering Data For Excel Files Using Pandas eddywinch82 9 6,095 Aug-06-2019, 03:44 PM
Last Post: eddywinch82
  Merge JSON files prioritizing the updated values from most recent file nebulae 0 2,537 Apr-17-2019, 10:15 AM
Last Post: nebulae
  Why can't I merge pandas dataframes learnpython2018 2 7,664 Sep-23-2018, 05:53 PM
Last Post: learnpython2018
  comparing two columns two different files in pandas nuncio 0 2,387 Jun-06-2018, 01:04 PM
Last Post: nuncio

Forum Jump:

User Panel Messages

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