import csv import random faker import faker datetime import datetime l=faker('en_gb') f=open("test.csv","r") k=csv.reader(f) g=open("1.csv","w") w=csv.writer(g) w.writerow(('id','name','address','college','company','dob','age')) in range(20000): w.writerow((i+1,l.name(),l.address(),random.choice(['psg','sona','amirta','anna university']),random.choice(['cts','infy','htc']),(random.randrange(1950,1995,1),random.randrange(1,13,1),random.randrange(1,32,1)),random.choice(range(0,100)))) f.close() when increase range 10000000 terminal kills process...... please can me . how can generate larger csv file random data .
if you're using python 2, range create list , may therefore have memory troubles large input values.
if that's case, use xrange instead. has fixed memory requirements regardless of input value.
the python 3 range more akin python 2 xrange shouldn't problem there.
Comments
Post a Comment