public
Created

python is for computer scientists ?

  • Download Gist
python_computer_scientists.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
import csv
import StringIO
 
data = """Bob,Dobbs,bob@dobbs.com,25.00
Rocket J.,Squirrel,rocky@frostbite.com,0.00
Bullwinkle,Moose,bull@frostbite.com,0.25
Vim,Wibner,vim32@goomail.com,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', 'bob@dobbs.com', '25.00']
# ['Rocket J.', 'Squirrel', 'rocky@frostbite.com', '0.00']
# ['Bullwinkle', 'Moose', 'bull@frostbite.com', '0.25']
# ['Vim', 'Wibner', 'vim32@goomail.com', '25.00']
# Printing twice
#
# Printing over

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.