Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
python is for computer scientists ?
import csv
import StringIO
data = """Bob,Dobbs,,25.00
Rocket J.,Squirrel,,0.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', '', '25.00']
# ['Rocket J.', 'Squirrel', '', '0.00']
# ['Bullwinkle', 'Moose', '', '0.25']
# ['Vim', 'Wibner', '', '25.00']
# Printing twice
# Printing over
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment