Last active
August 29, 2015 14:17
-
-
Save matuu/8a5c1e41619e8a0cb182 to your computer and use it in GitHub Desktop.
Parsea un csv tipo clave-valor a tupla (python)
This file contains hidden or 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
#!/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