Created
July 5, 2017 00:07
-
-
Save mmas/8f869068fad0b155748bf2733f4c0319 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
#!/usr/bin/env python | |
import sys | |
for line in sys.stdin: | |
if line.startswith('"'): | |
index = line.find('"', 1) | |
fields = [line[1:index]]+line[index+2:].split(',') | |
else: | |
fields = line.split(',') | |
print '\t'.join([ | |
fields[1], # Id. | |
fields[0], # Name. | |
fields[2], # Continent id. | |
str(int(fields[8])*1000) if fields[8] else '', # Population. | |
str(float(fields[10])/100) if fields[10] else '', # Urban population. | |
str(float(fields[14])/100) if fields[14] else '', # Population > 60. | |
str(float(fields[15])/100) if fields[15] else '', # Population < 15. | |
fields[5], # GNI per capita. | |
fields[129]]) # Life expectancy. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment