Python faker.providers.internet() Examples

The following are 1 code examples of faker.providers.internet(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module faker.providers , or try the search function .
Example #1
Source File: script.py    From dockerfiles with MIT License 6 votes vote down vote up
def generate_file(filename, generated_type):
    print("Generating " + filename)
    with open(filename, 'w', newline='') as csvfile:
        writer = csv.writer(csvfile, delimiter=',',
                            quotechar='"', quoting=csv.QUOTE_MINIMAL)
        generated_set = set()
        fake = Faker()
        fake.add_provider(internet)
        fake.add_provider(date_time)
        soFar = 0
        total = 2000000
        while len(generated_set) != total:
            indicator, csv_line = generate_indicator(fake, generated_type)
            if indicator in generated_set:
                continue
            generated_set.add(indicator)
            writer.writerow(csv_line)
            soFar += 1
            if (soFar % 10000 == 0):
                print(f"Finished {soFar} out of {total}")

    print("Finished" + filename)