Skip to content

Instantly share code, notes, and snippets.

@quantenProjects
Created June 23, 2017 19:16
Show Gist options
  • Save quantenProjects/1eb1d900c13df3c7bdc0f852e1c03f7e to your computer and use it in GitHub Desktop.
Save quantenProjects/1eb1d900c13df3c7bdc0f852e1c03f7e to your computer and use it in GitHub Desktop.
Dirty script to convert WEO csv data to one Year each row
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