On Tuesday, 26 April 2016 17:09:10 UTC+1, Joel Goldstick wrote: > On Tue, Apr 26, 2016 at 12:01 PM, <peakgraph...@gmail.com> wrote: > > I am wondering how to make my code function so it does not allow any of the > > same values to be entered into a column in my CSV file created through > > python. So I need to read into the CSV file and check if any names have > > already been entered. If they have, the user must not be allowed to enter > > this value. > > > > Thanks in advance! > > -- > > https://mail.python.org/mailman/listinfo/python-list > > Show your code and a few lines of your file with useful data. Show > the result you want > > -- > Joel Goldstick > http://joelgoldstick.com/blog > http://cc-baseballstats.info/stats/birthdays
Here's my section of code: with open(class_code+".csv", 'a') as csvfile: fieldnames = ["Name", "Score 1", "Score 2", "Score 3", "Average"] writer = csv.DictWriter(csvfile, fieldnames=fieldnames) #writer.writeheader() writer.writerow({"Name": name, "Score 1": score1, "Score 2": score2, "Score 3": score3}) It prints when requested as: Adam,1,0,0,0.3333333333333333 Jake,9,10,6,8.333333333333334 Tom,5,3,3,3.6666666666666665 So basically, if anyone called Adam, Jake or Tom tries the quiz again, it will not let them. Thanks -- https://mail.python.org/mailman/listinfo/python-list