Created
March 14, 2013 08:18
-
-
Save jj1bdx/5159722 to your computer and use it in GitHub Desktop.
A crude example of dumping reversebeacon.net CSV files to Riak via riak-python-client
This file contains 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
#!/usr/local/bin/python | |
import sys | |
import json | |
import csv | |
import riak | |
#client = riak.RiakClient() | |
cl = riak.RiakClient(host=YOURHOST, pb_port=YOUR_PB_PORT, protocol='pbc') | |
b = cl.bucket('records_rb') | |
fname = ['callsign', 'de_pfx', 'de_cont', 'freq', 'band', 'dx', 'dx_pfx', 'dx_cont', 'mode', 'db', 'date'] | |
fn = './rb_csv/' + sys.argv[1] + '.csv' | |
f = open(fn, "r") | |
for row in csv.DictReader(f, fieldnames=fname): | |
item = b.new(data=row) | |
item.store() | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment