Created
November 25, 2015 10:17
-
-
Save Innarticles/af92fa121710fc4e94c6 to your computer and use it in GitHub Desktop.
data_nasa.py
This file contains hidden or 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 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