An open API service indexing awesome lists of open source software.

https://github.com/supercili0usme/table-filler

Table-Filler: A simple Python library for generating test data for SQL, JSON, and CSV. Supports Faker and custom data types.
https://github.com/supercili0usme/table-filler

csv data-generation faker json python sql table-generator

Last synced: 5 months ago
JSON representation

Table-Filler: A simple Python library for generating test data for SQL, JSON, and CSV. Supports Faker and custom data types.

Awesome Lists containing this project

README

          

# Table-Filler πŸ—οΈ

**Table-Filler** is a library for generating test data for SQL tables, JSON, and CSV.

## Installation πŸ“¦
```sh
pip install tablefiller
```
Or install the latest version from GitHub:
```sh
pip install git+https://github.com/Supercili0usMe/table-filler.git
```

## Quick Start πŸš€
```python
from tablefiller import DataGenerator, Table
from tablefiller.types import Int, Str, Date

schema = Table(columns={
"id": Int(5, 10),
"name": Str(10),
"created_at": Date("01.01.2022", "31.12.2023", '%d.%m.%Y')
}, local="en")

generator = DataGenerator(schema)
data = generator.generate_data(5)

print(data.to_pandas()) # Output to DataFrame
data.to_csv("output.csv") # Save to CSV
```

## Features 🎯
βœ”οΈ Generate numbers, strings, dates, and categories
βœ”οΈ Faker support (names, addresses, emails)
βœ”οΈ Export to **CSV, JSON, SQL**
βœ”οΈ **pandas.DataFrame** support
βœ”οΈ Π‘ustom data types

## Available Data Types πŸ—οΈ
| Type | Description |
| ------------------ | --------------------------------------- |
| `Int(a, b)` | Integer from `a` to `b` |
| `Float(a, b, d)` | Number with `d` decimal places |
| `Str(n)` | String of length `n` |
| `Date(start, end)` | Random date within range |
| `Category([...])` | Category from a list |
| `Job("type")` | Faker data (`male`, `female`, `both`) |
| `Phone()` | Faker data |
| `Email("type")` | Faker data (`email`, `free`, `company`) |
| `Name("type")` | Faker data (`male`, `female`, `both`) |
| `Address("type")` | Faker data (`street`, `city`, `full`) |

## Data Export πŸ“€
```python
data.to_csv("output.csv") # CSV
data.to_json("output.json") # JSON
data.to_sql("output.sql") # SQL
```

## Creating Custom Data Types πŸ”§
```python
import random
from table_filler.types import DataType

class HexColor(DataType):
def generate(self):
return f"#{random.randint(0, 0xFFFFFF):06x}"

schema = TableSchema(columns={"id": Int(3), "color": HexColor()})
```

## Testing βœ…
```sh
pytest tests/
```

## License πŸ“œ
**MIT License**