Saturday, December 20, 2014

Random row

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+unsubscribe@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/07b16c6a-ca3a-4b42-8c72-33981c05d317%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment