Exemple #1
0
def generate_locations(file_name):
    with open(file_name, 'w', encoding='utf-8') as file:
        for i in range(0, number_of_locations):
            location_id = i + 1
            country = faker.country()
            city = faker.word().capitalize() + ' City'
            population = random.choice(population_categories)

            location = Location(location_id, country, city, population)
            locations.append(location)

            file.write(location.csv_format())
            if i != number_of_locations - 1:
                file.write('\n')
Exemple #2
0
def generate_locations_t2(file_name):
    with open(file_name, 'w', encoding='utf-8') as file:
        for i in range(0, number_of_locations):
            if i % 5 == 0:
                locations[i].set_population(
                    random.choice(population_categories))
            file.write(locations[i].csv_format() + '\n')

        for i in range(0, int(number_of_locations / 10)):
            location_id = number_of_locations + i + 1
            country = faker.country()
            city = faker.word().capitalize() + ' City'
            # city = faker.city()
            population = faker.random_int(40000, 98829389)

            location = Location(location_id, country, city, population)
            locations.append(location)

            file.write(location.csv_format())
            if i != int(number_of_locations / 10) - 1:
                file.write('\n')