Skip to content

Instantly share code, notes, and snippets.

@Innarticles
Created November 25, 2015 10:17
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 Innarticles/af92fa121710fc4e94c6 to your computer and use it in GitHub Desktop.
Save Innarticles/af92fa121710fc4e94c6 to your computer and use it in GitHub Desktop.
data_nasa.py
import sys
import getopt
import csv
import argparse
def main(argv):
args = getopt.getopt(argv, "")
args = str(args[1][0])
print args
def get_cnt(lVals):
d = dict(zip(lVals, [0] * len(lVals)))
for x in lVals:
d[x] += 1
return d
print "Im inno"
url = []
with open(args) as tsvfile:
# with open("sample_100.tsv") as tsvfile:
tsvreader = csv.reader(tsvfile, delimiter="\t")
for line in tsvreader:
url.append(line[4:5][0])
url_map = get_cnt(url)
print get_cnt(url)
writer = csv.writer(open('dict.csv', 'wb'))
for key, value in url_map.items():
writer.writerow([key, value])
if __name__ == "__main__":
main(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment