Skip to content

Instantly share code, notes, and snippets.

Created December 27, 2012 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4386447 to your computer and use it in GitHub Desktop.
Save anonymous/4386447 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import csv
def main():
d = {}
with open("output.csv", "rb") as f:
csv_reader = csv.reader(f)
for row in csv_reader:
if row[4] and row[15]:
key = row[4] + row[15]
if key not in d:
d[key] = 1
else:
d[key] += 1
# with open("output.csv", "rb") as f:
# for line in f:
# line = line.rstrip('\n')
# row = line.split(',')
# if row[4] and row[15]:
# key = row[4] + row[15]
# if key not in d:
# d[key] = 1
# else:
# d[key] += 1
for key, value in d.iteritems():
# print '> key:', key
# print '> value:', value
print (str(key) + ": " + str(value))
if __name__ == "__main__":
main()
# -*- coding: utf-8 -*-
# import csv
def main():
d = {}
# with open("output.csv", "rb") as f:
# csv_reader = csv.reader(f)
# for row in csv_reader:
# if row[4] and row[15]:
# key = row[4] + row[15]
# if key not in d:
# d[key] = 1
# else:
# d[key] += 1
with open("output.csv", "rb") as f:
for line in f:
line = line.rstrip('\n')
row = line.split(',')
if row[4] and row[15]:
key = row[4] + row[15]
if key not in d:
d[key] = 1
else:
d[key] += 1
for key, value in d.iteritems():
# print '> key:', key
# print '> value:', value
print (str(key) + ": " + str(value))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment