Skip to content

Commit

Permalink
Merge pull request #6 from IQSS/5-tsv
Browse files Browse the repository at this point in the history
add script to create TSV file from JSON data #5
  • Loading branch information
pdurbin authored Sep 26, 2019
2 parents b783551 + 6320653 commit 9095567
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions json2tsv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python3
import urllib.request as urlrequest
import json
import csv
onmap = 'https://services.dataverse.harvard.edu/miniverse/map/installations-json'
response = urlrequest.urlopen(onmap)
map_json = json.loads(response.read().decode(response.info().get_param('charset') or 'utf-8'))
installations = map_json['installations']
with open('dataverse-installations.tsv', 'w', newline='') as tsvfile:
output = csv.writer(tsvfile, delimiter='\t')
output.writerow(installations[0].keys()) # header row
for i in installations:
output.writerow(i.values())

0 comments on commit 9095567

Please sign in to comment.