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
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 thi
Doh sorry, hit return too quickly.
return random.choice(namesreader)
On Sat, Dec 20, 2014 at 9:42 PM, Cal Leeming wrote:
> Somewhat off-topic for django-users, this would have been better placed on
> StackOverflow.
>
> If I understood your question correctly, I think you need to remove the
> "f
you keep overwriting your random_choice every time the loop is run,
getting the last result is expected
On Sat, Dec 20, 2014 at 4:37 PM, Dariusz Mysior wrote:
> 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():
> w
Somewhat off-topic for django-users, this would have been better placed on
StackOverflow.
If I understood your question correctly, I think you need to remove the
"for row in namesreader" and replace with;
namesreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
return random.choice(row)
O
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 (
6 matches
Mail list logo