Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
merging two csv files
#4
Don't make a string out of it first. You make a string out of it, and then zip a list of just the string. Zipping a list of one item does nothing. Zip takes multiple lists and transposes them, so you need to give it multiple lists with multiple items each. Then you print the results rather than writing them to the file. Since datadict is a lists of the lists you want to zip, you need to unpack it with the star operator (*). So remove datadict = str(datadict), and change your for loop to:

for row in zip(*datadict):
    writer.writerow(row)
print('Done')
Note that you don't need an explicit quit() at the end of a program. Finally, since datadict is a list, please don't call it a dict. It makes your code confusing.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
merging two csv files - by jlcolam - Jul-13-2017, 11:05 AM
RE: merging two csv files - by ichabod801 - Jul-13-2017, 12:55 PM
RE: merging two csv files - by jlcolam - Jul-13-2017, 01:45 PM
RE: merging two csv files - by ichabod801 - Jul-13-2017, 06:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Merging multiple csv files with same X,Y,Z in each Auz_Pete 3 1,232 Feb-21-2023, 04:21 AM
Last Post: Auz_Pete
  Help needed with merging two CSV files eyadfr 5 3,053 Dec-14-2021, 07:34 PM
Last Post: paul18fr
  Sorting and Merging text-files [SOLVED] AlphaInc 10 5,003 Aug-20-2021, 05:42 PM
Last Post: snippsat
  Merging all file_name.log's files from directory to one and search “PerformanceINFO" sutra 0 1,809 Dec-09-2020, 05:14 PM
Last Post: sutra
  Merging Excel Files JezMim 1 1,932 Sep-06-2020, 08:56 PM
Last Post: bowlofred
  Merging CSV Files in Jupyter RJ117 0 4,793 Jan-07-2018, 06:24 AM
Last Post: RJ117

Forum Jump:

User Panel Messages

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