Created
January 17, 2012 14:40
-
-
Save dnene/1626867 to your computer and use it in GitHub Desktop.
python is for computer scientists ?
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
import csv | |
import StringIO | |
data = """Bob,Dobbs,[email protected],25.00 | |
Rocket J.,Squirrel,[email protected],0.00 | |
Bullwinkle,Moose,[email protected],0.25 | |
Vim,Wibner,[email protected],25.00""" | |
data_stream = StringIO.StringIO(data) | |
dataReader = csv.reader(data_stream) | |
#dataReader = list(csv.reader(data_stream)) <-- equivalent to toIndexedSeq | |
print "Printing once" | |
print "\n".join(map(lambda x: str(x), dataReader)) | |
print "Printing twice" | |
print "\n".join(map(lambda x: str(x), dataReader)) | |
print "Printing over" | |
# Actual Output | |
# Printing once | |
# ['Bob', 'Dobbs', '[email protected]', '25.00'] | |
# ['Rocket J.', 'Squirrel', '[email protected]', '0.00'] | |
# ['Bullwinkle', 'Moose', '[email protected]', '0.25'] | |
# ['Vim', 'Wibner', '[email protected]', '25.00'] | |
# Printing twice | |
# | |
# Printing over |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment