Yet another Python package for data generation
Project description
Fake data generator
This package generates fake sql-like format data from predefined schema. Data schema is defined using dataclasses.
Installation
python -m pip install no_spark_in_my_home
Usage
from datetime import datetime
from dataclasses import dataclass
from no_spark_in_my_home.src.generator import FakeDataGenerator
@dataclass
class Dataclass:
item_id: int
title: str
date: datetime
number: int
gen = FakeDataGenerator(
Dataclass,
limit=5,
)
spark_dataframe = gen.load()
spark_dataframe.show()
FakeDataGenerator params:
model- dataclasslimit- number of recordsmask_per_field- dict with masks per field. Example:FakeDataGenerator(..., mask_per_field={"title": "A#### ###."})range_per_field- dict with ranges per field. Example:FakeDataGenerator(..., range_per_field={"number": {"range": range(1, 10)}})maxlength_per_field- dict with maxlengths for strings per field. Example:FakeDataGenerator(..., maxlength_per_field={"field_name": "title", "maxlength": 100, "fixed": True}).fixed=Truewill generate strings with fixed length.fixed=Falsewill generate strings with non-fixed, but limited lengths.config- path to config. Config should be yaml-formatted.lang- locale. Default - "en"foreign_keys- list of dicts that describes relations. Example:FakeDataGenerator(..., foreign_keys=[{"self_field": "item_id", "other_field": "another_item_id", "other_model": OtherDataclass, "other_data": other_dataclass_gen.load(as_dicts=True)}])
load params:
where_clause- string with where-clause for post-filtering. Example:load(..., where_clause="item_id > 5 and number = 10")as_json- if True returns generated data as jsonas_dicts- if True returns generated data as list of dicts
Building your own package version
In case you want to build your own package version you should follow this guide.
And then just build a wheel and install it.
Making and publishing a new release
- Update release version in pyproject.toml and setup.py
- Build package with
python -m build - Publish package with
twine upload dist/*
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file no_spark_in_my_home-1.0.4.tar.gz.
File metadata
- Download URL: no_spark_in_my_home-1.0.4.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e22d1a613b973a69f36b4940737cfc3e8ac75aafa757698f8bc1d1b7c8d43a1
|
|
| MD5 |
980fd7b6b7fafe32753f372410a7fb1c
|
|
| BLAKE2b-256 |
c91e2c6ee029dde2da6dd3f7798610997c696395c487ec5887518c555b8112d0
|
File details
Details for the file no_spark_in_my_home-1.0.4-py3-none-any.whl.
File metadata
- Download URL: no_spark_in_my_home-1.0.4-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4848eb67c6c21b173d7a302867d5c3a289f394f3269621609ede62ce9f5b3f2
|
|
| MD5 |
24ffc13a2ba0acbb9cf0a33c74212d76
|
|
| BLAKE2b-256 |
cb5ee2e51fbede7ea2f0b3a5e6e47acc99b8327a5ea27c040e451e0af03c2ea1
|