Created
June 23, 2017 19:16
-
-
Save quantenProjects/1eb1d900c13df3c7bdc0f852e1c03f7e to your computer and use it in GitHub Desktop.
Dirty script to convert WEO csv data to one Year each row
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
inputFile = open("WEOApr2017all.csv","r") | |
outputFile = open("output.csv","w") | |
allLines = inputFile.readlines() | |
print allLines[0].split("\t")[0:9] | |
outputFile.write("\t".join(allLines[0].split("\t")[0:9]) + "\tYear\tValue"+ "\n") | |
for i in allLines[1:-2]: | |
akkList = i.split("\t") | |
for j in xrange(43): | |
if akkList[9+j] != "n/a": | |
tmpStr = "\t".join(akkList[0:9]) + "\t" + str(1980+j) + "\t" + akkList[9+j].replace(",","").replace(".",",") | |
#print tmpStr | |
outputFile.write(tmpStr+"\n") | |
outputFile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment