Last active
May 25, 2016 11:40
-
-
Save zeffii/3a3847fb8de789d5aa54682cadff57d3 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
import os | |
import csv | |
import json | |
import collections | |
from collections import defaultdict | |
filename = r"C:\Users\zeffi\Desktop\kooo\...\....worldcities.csv" | |
def open_csv_test(filename): | |
#csvfile = open(filename, 'r', encoding='ISO-8859-15', newline='') | |
csvfile = open(filename, 'r', encoding='ISO-8859-15', newline='') | |
ofile = csv.reader(csvfile, delimiter=',') | |
with open(r'C:\Users\zeffi\Desktop\kooo\...\....\worldcities_redux.csv', 'w') as wfile: | |
next(ofile) | |
for i, row in enumerate(ofile): | |
if row[4]: | |
if int(row[4]) > 500000: | |
# wfile.write("%s,%s,%s\n" % tuple(row[4:])) | |
wfile.write("{0:1d},{1:.3f},{2:.3f}\n".format(int(int(row[4])/1000), float(row[5]), float(row[6]))) | |
open_csv_test(filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment