Skip to content

Instantly share code, notes, and snippets.

@jcppkkk
Created May 21, 2012 14:50
Show Gist options
  • Save jcppkkk/2762736 to your computer and use it in GitHub Desktop.
Save jcppkkk/2762736 to your computer and use it in GitHub Desktop.
[python] Basics
## Dict Database for col_fam.batch_insert()
a={}
for r in range(3):
row_key='raw{}'.format(r)
a[row_key]={}
for i in range (5):
a[row_key]['name{}'.format(i)]='val{}'.format(i)
print a
##{'raw2': {'name4': 'val4', 'name2': 'val2', 'name3': 'val3', 'name0': 'val0', 'name1': 'val1'},
## 'raw0': {'name4': 'val4', 'name2': 'val2', 'name3': 'val3', 'name0': 'val0', 'name1': 'val1'},
## 'raw1': {'name4': 'val4', 'name2': 'val2', 'name3': 'val3', 'name0': 'val0', 'name1': 'val1'}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment