Mercurial > hg > LGDataverses
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 9:5926d6419569 | 10:a50cf11e5178 |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 import sys | |
| 3 from optparse import OptionParser | |
| 4 import csv | |
| 5 try: | |
| 6 import json | |
| 7 except ImportError: | |
| 8 import simplejson as json | |
| 9 | |
| 10 parser = OptionParser() | |
| 11 options, args = parser.parse_args() | |
| 12 | |
| 13 if args: | |
| 14 csv_file = open(args[0]) | |
| 15 else: | |
| 16 csv_file = sys.stdin | |
| 17 | |
| 18 reader = csv.DictReader(csv_file, delimiter="\t") | |
| 19 rows = [row for row in reader] | |
| 20 for row in rows: | |
| 21 print json.dumps(row) | |
| 22 csv_file.close() |
