{"id":18646450,"url":"https://github.com/creditdatamw/zefaker","last_synced_at":"2025-04-11T12:31:51.619Z","repository":{"id":43290872,"uuid":"243847502","full_name":"creditdatamw/zefaker","owner":"creditdatamw","description":"zefaker is a command-line tool for generating CSV, Excel, JSON and SQL files from a Groovy DSL","archived":false,"fork":false,"pushed_at":"2024-01-18T19:36:38.000Z","size":559,"stargazers_count":29,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T14:02:00.904Z","etag":null,"topics":["csv","dsl","excel","generate-data","groovy","json","testing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/creditdatamw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-28T20:19:26.000Z","updated_at":"2023-07-09T09:46:50.000Z","dependencies_parsed_at":"2022-07-22T05:32:08.490Z","dependency_job_id":null,"html_url":"https://github.com/creditdatamw/zefaker","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creditdatamw%2Fzefaker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creditdatamw%2Fzefaker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creditdatamw%2Fzefaker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creditdatamw%2Fzefaker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/creditdatamw","download_url":"https://codeload.github.com/creditdatamw/zefaker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248401982,"owners_count":21097328,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csv","dsl","excel","generate-data","groovy","json","testing"],"created_at":"2024-11-07T06:19:57.340Z","updated_at":"2025-04-11T12:31:50.979Z","avatar_url":"https://github.com/creditdatamw.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Zé Faker\n========\n\n`zefaker` is a command-line tool that helps developers generate and export data into CSV, Excel and SQL files for testing their applications.\n\n## Features\n\n* Random data generation via [java-faker](https://github.com/DiUS/java-faker) with Locale support\n* Export to CSV\n* Export to Excel Sheet\n* Export to SQL INSERTS\n* Export to SQL COPY (for PostgreSQL)\n* Export to JSON\n* Export to JSON Lines\n\n## Why would I use this?\n\nShort answer **to generate (test) data**.\n\nIf you ever need to have a CSV, Excel file with (random*) data or need to \npopulate a database with development/dummy data you can use `zefaker` to \ngenerate the data, leveraging the power of [Groovy](https://www.groovy-lang.org)\n\nWe created it because we deal with a lot of Excel files (with lots of columns!) and SQL data and often have to generate files to test the code that processes those files or data.\n\n_* the generated data does not have to be random_\n\n## Example Usage\n\n\u003e NOTE: Checkout the [examples](./examples/) for even more examples, and \"advanced\" usage\n\nLet's go straight to an example:\n\nCreate a file named `person.groovy` and place the following content:\n\n```groovy\n// person.groovy\n\nlocale(\"en-GB\") // tells Java Faker to use the given tag for the Locale.\n\n// You can also use a custom faker\n// import net.datafaker.Faker\n// useFaker(new Faker(Locale.getLanguageTag(\"en-GB\")))\n\ngenerateData([\n    \"FirstName\": { faker -\u003e faker.name().firstName() },\n    \"LastName\": { faker -\u003e faker.name().lastName() },\n    \"Age\": { faker -\u003e faker.number().numberBetween(18, 70) },\n    \"AccountStatus\": { faker -\u003e faker.options().option(\"Open\", \"Closed\") },\n    \"Plan\": { faker -\u003e \"FREE\" } // doesn't necessarily have to be a faker value\n])\n```\n\nOnce you have this, you can pass it to the `zefaker` command to generate a file:\n\n### Exporting as a CSV File\n\n```sh\n$ zefaker -f person.groovy -rows 1000 -output people.csv -csv \n```\n\nThe example command, above, generates a file named **people.csv** with **1000 rows** \npopulated with data generated using the Faker functions specified in the Groovy script.\n\n### Exporting as an Excel file\n\n```sh\n$ zefaker -f person.groovy -rows 1000 -output people.xlsx -sheet People\n```\n\nThe example command, above, generates a file named **people.xlsx** with **1000 records**.\n\n\u003e _Bonus / Shameless plug_: If you're using Java, you can process the generated files _quickly_ and \n_efficiently_ using [zerocell](https://github.com/creditdatamw/zerocell).\n\n### Exporting as an SQL file\n\n```sh\n$ zefaker -f person.groovy -rows 1000 -output people.sql -sql -table people \n```\n\nThe example command, above, generates a file named **people.sql** with \n**1000 INSERT statements** which have random data in the _VALUES_ clause.\n\n### Exporting as a JSON file\n\n```sh\n$ zefaker -f person.groovy -rows 1000 -output people.json -json \n```\n\nThe example command, above, generates a file named **people.json** with **1000 JSON objects**.\n\n\n## Installation\n\nDownload a copy of `zefaker` from the [Releases](https://github.com/creditdatamw/zefaker/releases) page.\n\n\u003e NOTE: Requires at least Java 8 to be installed\n\n## Usage\n\nThe build archive contains start scripts, `zefaker` and `zefaker.bat` for UN*X and Windows environments, respectively.\n\n### Command Line\n\n```sh\nUsage: zefaker [options]\n  -f=FILE         Groovy file with column definitions\n  -rows=ROWS      Number of rows to generate\n  -output=FILE    File to write to, e.g. generated.xlsx\n  -sheet=NAME     Sheet name in the generated Excel file\n  -table=NAME     The name of the table to use in SQL INSERT mode\n  -sql            Use SQL INSERT export mode\n  -vvv            Show verbose output\n  -x              Overwrite existing file\n```\n\n### Web based UI\n\nYou can run the following `java -jar zefaker.jar -web` to start a webserver at port `4567`:\n\n![[]](zefakerweb.png)\n\n### In the Groovy Script\n\nWithin your Groovy script you are required to use the *generateFrom(\u003cmap\u003e)* \nfunction to generate the Excel file.\n\n#### Methods\n\nThe following are the only methods that are required in the groovy script for \nZefaker to run. \n\n**ColumnDef column(int index, String name)**\n\n\nThis method defines a new Column that has a name and an index (position)\n\n**void generateFrom(ColumnDef[] columns)**\n\nThis method actually initiates the generation of the Excel file. If you don't\ncall this method you won't actually get any result. \n\nExample: `generateFrom([ (firstName) : { faker -\u003e faker.name().firstName() } ])`\n\n#### Properties\n\nInside the Groovy script you can set some variables or properties that affect the \noutput of zefaker. These variables, consequently, take precedence over arguments \nspecified on the command-line. \n\nThe following special variables are available, and are therefore *reserved names*:\n\n* **sheetName** - Change the name of the target Sheet in Excel. Overrides `-sheet`\n* **tableName** - Change the name of the target table in SQL INSERTS. Overrides `-table`\n* **outputFile** - The name/path of the file to write output to. Overrides `-f`\n* **verbose** - Show verbose output. Overrides `-vvv`\n* **maxRows** - Sets the maximum number of rows to generate in the file. Overrides `-rows`\n* **overwriteExisting** - Whether to overrite an existing file with the new Workbook. Overrides `-x`\n\n## Building\n\nWe are using `Gradle` for this, so follow the instructions below to build it.\n\n```sh\n$ git clone https://github.com/creditdatamw/zefaker.git\n$ cd zefaker\n$ gradlew clean build\n```\n\nAfter this, the build file will be in `build/libs/zefaker-all.jar` - it is an executable Jar file.\n\n## Using Docker\n\nYou will have to build the image locally at the moment, :). Then run:\n\n```sh\n$ docker run --volume \"$(pwd):/tmp:rw\" zefaker -f /tmp/example.groovy -output /tmp/first.sql -sql \n```\n\n## CONTRIBUTING\n\nHelp out by resolving an issue in the [issue tracker](https://github.com/creditdatamw/zefaker/issues). \nPull Requests are welcome. If you run into a problem, create an issue and we will try to resolve it.\n\n---\n\nCopyright (c) 2022, Credit Data CRB Ltd","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreditdatamw%2Fzefaker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcreditdatamw%2Fzefaker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreditdatamw%2Fzefaker/lists"}