Skip to content

Instantly share code, notes, and snippets.

@joeljacobson
Created February 17, 2014 21:44
Show Gist options
  • Save joeljacobson/9059856 to your computer and use it in GitHub Desktop.
Save joeljacobson/9059856 to your computer and use it in GitHub Desktop.
python, riak bulk import
import csv
import json
import riak
# dna,sex,name,address,city,state,zip,social,dob,phone,occupation,blood,weight,lat,long
client = riak.RiakClient(pb_port=8087, protocol='pbc')
bucket = client.bucket('za')
f = open("/usr/src/ZA10k.csv", "r")
for row in csv.DictReader(f):
key = row['social']
item = bucket.new(row['social'], data=row)
item.add_index('social_bin', row['social'])
item.add_index('city_bin', row['city'])
item.add_index('state_bin', row['state'])
item.add_index('blood_bin', row['blood'])
item.add_index('weight_bin', row['weight'])
item.store()
print('.'),
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment