Python Forum
Python script merging some columns to one column with new name
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python script merging some columns to one column with new name
#4
You need to translate the rows according to the plan, so replace the lines 77 to 88 by
fieldnames = [pair[0] for pair in plan]
 
writer = csv.DictWriter(outfile, delimiter=';', fieldnames=fieldnames, extrasaction='ignore')
headers = {n: n for n in writer.fieldnames}
writer.writerow(headers)
for row in reader:
    new_row = merge(plan, row)
    writer.writerow(new_row)
Reply


Messages In This Thread
RE: Python script merging some columns to one column with new name - by Gribouillis - Feb-13-2020, 10:31 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Converting column of values into muliple columns of counts highland44 0 301 Feb-01-2024, 12:48 AM
Last Post: highland44
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,475 Jun-29-2023, 11:57 AM
Last Post: gologica
  J2534 Python Can Bus merging natezoom 0 762 May-01-2023, 10:37 PM
Last Post: natezoom
  Reshaping a single column in to multiple column using Python sahar 7 2,140 Jun-20-2022, 12:35 PM
Last Post: deanhystad
  df column aggregate and group by multiple columns SriRajesh 0 1,093 May-06-2022, 02:26 PM
Last Post: SriRajesh
  Transform 3 Columns into Single Column DaveG 8 1,946 Apr-04-2022, 08:42 AM
Last Post: Pedroski55
  Split single column to multiple columns SriRajesh 1 1,371 Jan-07-2022, 06:43 PM
Last Post: jefsummers
  How to remove a column or two columns in a correlation heatmap? lulu43366 3 5,356 Sep-30-2021, 03:47 PM
Last Post: lulu43366
  Merging spreadsheets with the same columns and extracting rows with matching entries johnbernard 3 11,114 Aug-19-2021, 03:08 PM
Last Post: johnbernard
  Index error - columns vs non-column Vinny 3 5,000 Aug-09-2021, 04:46 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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