Last active
March 11, 2016 05:51
-
-
Save alex-hofsteede/dec3be4b0fccbd682124 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A | B | C | 1 | 2 | 3 | |
---|---|---|---|---|---|---|
Z | Y | X | 1 | 2 | 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import sys | |
with open(sys.argv[1], "rU") as f: | |
reader = csv.reader(f) | |
writer = csv.writer(sys.stdout) | |
split = 4 # how many common columns at the beginning | |
for i, row in enumerate(reader): | |
if i == 0: | |
header = row | |
else: | |
for x in range(split, len(row)): | |
writer.writerow(row[1:split] + [header[x]] + [row[x]]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment