Mercurial > hg > LGDataverses
diff scripts/search/tab2json-users @ 10:a50cf11e5178
Rewrite LGDataverse completely upgrading to dataverse4.0
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 08 Sep 2015 17:00:21 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/search/tab2json-users Tue Sep 08 17:00:21 2015 +0200 @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import sys +from optparse import OptionParser +import csv +try: + import json +except ImportError: + import simplejson as json + +parser = OptionParser() +options, args = parser.parse_args() + +if args: + csv_file = open(args[0]) +else: + csv_file = sys.stdin + +reader = csv.DictReader(csv_file, delimiter="\t") +rows = [row for row in reader] +for row in rows: + print json.dumps(row) +csv_file.close()