예제 #1
0
파일: utils.py 프로젝트: Pigueiras/pyes
def generate_dataset(number_items=1000):
    """
    Generate a dataset with number_items elements.
    """
    data = []
    names = get_names()
    totalnames = len(names)
    #init random seeder
    random.seed()
    #calculate items
#    names = random.sample(names, number_items)
    for i in xrange(number_items):
        data.append({"name":names[random.randint(0,totalnames-1)],
                     "age":random.randint(1,100),
                     "description":li_words(50, False)})
    return data
예제 #2
0
파일: utils.py 프로젝트: zebuline/pyes
def generate_dataset(number_items=1000):
    """
    Generate a dataset with number_items elements.
    """
    data = []
    names = get_names()
    totalnames = len(names)
    #init random seeder
    random.seed()
    #calculate items
    #    names = random.sample(names, number_items)
    for i in xrange(number_items):
        data.append({
            "name": names[random.randint(0, totalnames - 1)],
            "age": random.randint(1, 100),
            "description": li_words(50, False)
        })
    return data
예제 #3
0
파일: utils.py 프로젝트: Pigueiras/pyes
def generate_dataset_shelve(filename, number_items=1000):
    """
    Generate a dataset with number_items elements.
    """
    if os.path.exists(filename):
        os.remove(filename)
    data = shelve.open(filename)
    names = get_names()
    totalnames = len(names)
    #init random seeder
    random.seed()
    #calculate items
#    names = random.sample(names, number_items)
    for i in xrange(number_items):
        data[str(i+1)] = {"name":names[random.randint(0,totalnames-1)],
                     "age":random.randint(1,100),
                     "description":li_words(50, False)}
    data.close()
예제 #4
0
파일: utils.py 프로젝트: zebuline/pyes
def generate_dataset_shelve(filename, number_items=1000):
    """
    Generate a dataset with number_items elements.
    """
    if os.path.exists(filename):
        os.remove(filename)
    data = shelve.open(filename)
    names = get_names()
    totalnames = len(names)
    #init random seeder
    random.seed()
    #calculate items
    #    names = random.sample(names, number_items)
    for i in xrange(number_items):
        data[str(i + 1)] = {
            "name": names[random.randint(0, totalnames - 1)],
            "age": random.randint(1, 100),
            "description": li_words(50, False)
        }
    data.close()