Skip to content

Instantly share code, notes, and snippets.

@matuu
Last active August 29, 2015 14:17
Show Gist options
  • Save matuu/8a5c1e41619e8a0cb182 to your computer and use it in GitHub Desktop.
Save matuu/8a5c1e41619e8a0cb182 to your computer and use it in GitHub Desktop.
Parsea un csv tipo clave-valor a tupla (python)
#!/usb/bin/env python
# -*- coding: utf-8 -*-
import sys
if len(sys.argv) > 2:
print "Sólo un argumento, el nombre del csv"
exit -1
else:
print "TUPLE = ("
with open(sys.argv[1]) as file:
for l in file:
sl = l.split(',')
print "({}, u\"{}\"),".format(sl[0], sl[1][:-1])
print ")"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment