Created
April 21, 2017 16:51
-
-
Save vsee/9e989ee6d314aea0672a084086568465 to your computer and use it in GitHub Desktop.
generates square shaped transitions for a list of given data points.
This file contains hidden or 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
''' | |
This script generates square shaped transitions | |
for a list of given data points. | |
### Example | |
Input: | |
x,y | |
0,100 | |
5,430 | |
10,200 | |
Output: | |
x,y | |
0,100 | |
5,100 | |
5,430 | |
10,430 | |
10,200 | |
''' | |
import csv | |
import sys | |
if(len(sys.argv) < 3): | |
print("Usage: " + sys.argv[0] + " <input csv file> <output csv file>") | |
sys.exit(1) | |
infile = open(sys.argv[1],"r") | |
reader = csv.reader(infile,delimiter="\t") | |
outfile = open(sys.argv[2],"w") | |
writer = csv.writer(outfile) | |
last = None | |
skipHeader = True | |
for row in reader: | |
if(skipHeader): | |
writer.writerow(row) | |
skipHeader = False | |
continue | |
if(last != None): | |
writer.writerow([row[0], last]) | |
last = row[1] | |
writer.writerow(row) | |
infile.close() | |
outfile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment