[Tutor] write dictionary to file
Ian D
duxbuz at hotmail.com
Fri Jun 20 16:11:32 CEST 2014
>
> Ok making some progress by changing the 'wb' to 'w'
>
err no.
unstuck again.
import csv
csvfile= open('StudentListToSort.csv', newline='')
spamreader = csv.reader(csvfile,delimiter=',',quotechar='|')
outfile = open('outfile.csv','w')
for row in spamreader:
if row[4] == '6':
print("".join([row[0],'@email.com']),row[1])
email = "".join([row[0],'@email.com'])
output = email,row[1]
outfile.write(output)
outfile.close()
when I start to concatenate the results, it ends up as a Tuple and the write to file stuff doesn't like Tuples
TypeError: must be str, not tuple
More information about the Tutor
mailing list