Data Cloning with Python Generate Randomized Copies of Your Data!

PHOTO EMBED

Wed Aug 14 2024 13:45:52 GMT+0000 (Coordinated Universal Time)

Saved by @freepythoncode ##python #coding #python #programming #faker #database #sqlite3

from faker import Faker
from random import randint

f = Faker()

data = {'name': 'Barry Long', 'email': 'tammy28@example.com', 'age': 20}

# Generate data from this 
def Generate_like_this(data : dict, f : Faker):
    result = {}

    funcs = {
        'name': f.name,
        'email': f.email
    }

    for k in data:

        if k in funcs:
            result[k] = funcs[k]()

        if isinstance(data[k], int):
            result[k] = randint(1, data[k])
        
    
    return result

print(Generate_like_this(data = data, f = Faker()))
content_copyCOPY