Skip to content

Instantly share code, notes, and snippets.

@lazyval
Created September 23, 2012 20:21
Show Gist options
  • Save lazyval/3772931 to your computer and use it in GitHub Desktop.
Save lazyval/3772931 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# -*- coding: utf-8 -*-
filename = "dict.csv"
lookup = {}
with open(filename,"r") as file:
for line in file:
(key, value) = line.split(" ")[0:2]
lookup[key] = value
print(lookup)
pair = raw_input("Enter <address> <name> pair: ")
try:
file = open(filename, "a")
try:
file.write("\n")
file.write(pair)
finally:
file.close()
except IOError:
print("WTF! got an error "+IOError)
#!/usr/bin/python
# -*- coding: utf-8 -*-
filename = "dict.csv"
lookup = {}
with open(filename,"r") as file:
for line in file:
(key, value) = line.split(" ")[0:2]
lookup[key] = value
while(True):
address = raw_input("Enter <address> to lookup (Enter to exit): ")
if(address == ""):
break
if address in lookup:
print(lookup[address])
else:
print("No key found: ")
print("goodbue!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment