Skip to main content

A Python package for generating fake table data. Get data in pandas dataframe & pyarrow table or export to Csv, Json, Excel or Parquet

Project description

Table Faker

tablefaker is a versatile Python package that empowers you to effortlessly create realistic but synthetic table data for a wide range of applications. If you need to generate test data for software development, this tool simplifies the process with an intuitive schema definition in YAML format.

Key Features

Schema Definition: Define your target schema using a simple YAML file. Specify the structure of your tables, column names, fake data generation function, and relationships.

Faker and Randomization: Leverage the power of the Faker library and random data generation to create authentic-looking fake data that mimics real-world scenarios.

Multiple Output Formats: Generate fake data in various formats to suit your needs

  • Pandas Dataframe
  • CSV File
  • Parquet File
  • JSON File
  • Excel File

Installation

pip install tablefaker

Sample Yaml File

version: 1
tables:
  - table_name: person
    row_count: 10
    columns:
      - column_name: id
        data: row_id
      - column_name: first_name
        data: fake.first_name()
      - column_name: last_name
        data: fake.last_name()
      - column_name: age
        data: fake.random_int(18, 90)
      - column_name: dob
        data: fake.date_of_birth()
        null_percentage: 0.20
  - table_name: employee
    row_count: 5
    columns:
      - column_name: id
        data: row_id
      - column_name: person_id
        data: fake.random_int(1, 10)
      - column_name: hire_date
        data: fake.date_between()

full yml example

Sample Code

import tablefaker

tablefaker.to_csv("test_table.yaml") # exports to current folder in csv format
tablefaker.to_json("test_table.yaml", "./target_folder") # exports all tables in json format
tablefaker.to_parquet("test_table.yaml", "./target_folder") # exports all tables in parquet format
tablefaker.to_excel("test_table.yaml", "./target_folder/target_file.csv") # exports only the first table in excel format

Sample CLI Command

tablefaker --config test_table.yaml # exports to current folder in csv format
tablefaker --config test_table.yaml --file_type excel # exports to current folder in excel format
tablefaker --config test_table.yaml --file_type json --target ./target_folder # exports all tables in json format
tablefaker --config test_table.yaml --file_type parquet --target ./target_folder/target_file.parquet # exports only the first table

Sample CSV Output

id,first_name,last_name,age,dob
1,John,Smith,35,1992-01-11
2,Charles,Shepherd,27,1987-01-02
3,Troy,Johnson,42,
4,Joshua,Hill,86,1985-07-11
5,Matthew,Johnson,31,1940-03-31

Faker Functions List

https://faker.readthedocs.io/en/master/providers.html#

Bug Report & New Feature Request

https://github.com/necatiarslan/table-faker/issues/new

TODO

  • Foreign key
  • Custom Faker Provider support
  • Export To PostgreSQL
  • Parquet Column Types
  • Inline schema definition
  • Json schema file
  • Pyarrow table
  • Custom fake data creation function

Follow me on linkedin to get latest news
https://www.linkedin.com/in/necati-arslan/

Thanks,
Necati ARSLAN
necatia@gmail.com

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

tablefaker-1.0.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

tablefaker-1.0.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file tablefaker-1.0.0.tar.gz.

File metadata

  • Download URL: tablefaker-1.0.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for tablefaker-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7ede2d173b96ba02704fb4f710465c0344deb6bb4009132d4d29302f7333783c
MD5 fe8320046b39c4a6270099f0eef0ef16
BLAKE2b-256 6dcade9d1fc519d1d263080fb6e686bd6e2a9fb58e121051e1a7539b7d93594d

See more details on using hashes here.

File details

Details for the file tablefaker-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: tablefaker-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for tablefaker-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ac8f839e00df8568d423bee4e679661975671462d79e3dc22013b930750ea46
MD5 c1409649e8f1bbcf2421e5992e87d735
BLAKE2b-256 3cc927f614061b50a4b49d05336f2446b9598e04fffec127f35be1fb7d574994

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page