Hi, Are you sure you saved your code? There's a len() in your traceback that isn't in your code.
Collin On Saturday, December 20, 2014 3:50:11 PM UTC-6, Dariusz Mysior wrote: > > I change it on > > import csv, random > > def new_name(): > with open('PL_surnames.csv', newline='') as csvfile: > namesreader = csv.reader(csvfile, delimiter=' ', quotechar='|') > > random_choice=random.choice(namesreader) > return random_choice > print(new_name()) > > > > No I have this message > > Traceback (most recent call last): > File "C:/Python31/csv", line 10, in <module> > print(new_name()) > File "C:/Python31/csv", line 8, in new_name > random_choice=random.choice(namesreader*len(namesreader)) > TypeError: object of type '_csv.reader' has no len() > >>> > > > > W dniu sobota, 20 grudnia 2014 22:37:23 UTC+1 użytkownik Dariusz Mysior > napisał: >> >> Why I get only last row from my csv file, why I don't get in any time >> ranom row :/ >> >> import csv, random >> >> def new_name(): >> with open('PL_surnames.csv', newline='') as csvfile: >> namesreader = csv.reader(csvfile, delimiter=' ', quotechar='|') >> for row in namesreader: >> #print (','.join(row)) >> random_choice=random.choice(row) >> return random_choice >> print(new_name()) >> >> >> -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/789c3575-b89a-48c1-b0c8-4ac0ac56087b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.