Bottom Page

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.
Quote

Top Page

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
  Pandas dataframe merge snmmat 1 146 Mar-09-2020, 06:56 PM
Last Post: jefsummers
  Need Help With Filtering Data For Excel Files Using Pandas eddywinch82 9 870 Aug-06-2019, 03:44 PM
Last Post: eddywinch82
  Merge JSON files prioritizing the updated values from most recent file nebulae 0 671 Apr-17-2019, 10:15 AM
Last Post: nebulae
  Why can't I merge pandas dataframes learnpython2018 2 1,816 Sep-23-2018, 05:53 PM
Last Post: learnpython2018
  comparing two columns two different files in pandas nuncio 0 750 Jun-06-2018, 01:04 PM
Last Post: nuncio
  Pandas merge question smw10c 1 2,531 May-05-2017, 09:57 PM
Last Post: zivoni

Forum Jump:


Users browsing this thread: 1 Guest(s)