Created
June 17, 2010 13:36
-
-
Save ingenieroariel/442132 to your computer and use it in GitHub Desktop.
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
import redis | |
import json | |
cache = redis.Redis(host='localhost', port=6379, db=0) | |
keys = cache.keys().split(" ") | |
out = {} | |
bogota = open('bogota.txt', 'w') | |
for key in keys: | |
try: | |
sitio = json.loads(cache.get(key))[key] | |
if sitio[0] == "BOGOTA D.C.": | |
nombre = sitio[2] | |
direccion = sitio[3] | |
salida = '"%s", "%s"\n' % ( sitio[2], sitio[3].replace("&ndash", "-" )) | |
out[str(salida)] = salida | |
except: | |
pass | |
for key in out.values(): | |
bogota.write(key) | |
bogota.close() |
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
#sudo apt-get install redis-server git-core python-pip | |
#pip install -e git+http://github.com/andymccurdy/redis-py.git#egg=redis | |
#sudo /etc/init.d/redis-server stop | |
#sudo cp the_dump.rdb /var/lib/redis/dump.rdb | |
#sudo chown redis:redis /var/lib/dump.rdb | |
#sudo /etc/init.d/redis-server start | |
import redis | |
cache = redis.Redis(host='localhost', port=6379, db=0) | |
keys = cache.keys().split(" ") | |
for key in keys: | |
sitio = cache.get(key) | |
print sitio |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment