Random data, fakrs!
fakr reads a Jinja2 Template from stdin, renders it using a vocabulary and writes the result to stdout. It’s as simple as that…
Installation
$ pip install fakr
Basic Usage
$ fakr --help
Examples
Generate a simple csv file with 100k rows
$ echo "{{row}},{{row%100}},{{firstname}},{{lastname}},{{email}}" \
| fakr --count 100000``
Use a file for complex template
$ cat examples/templates/vcard.tpl \ | fakr --count 1000
Make a http request using curl:
$ echo "company={{company|urlencode}}&city={{city|urlencode}}" \
| fakr -c1 \
| curl httpbin.org/post -d @-
Write data to a redis server:
$ echo 'firstname \"{{firstname}}\" lastname \"{{lastname}}\" email \"{{email}}\"' \
| fakr \
| xargs -i redis-cli HMSET {}``
Templates
The templates you use for data generation are plain Jinja2 Templates. See their reference for detailed information.
There are a few custom filters, functions and variables for use with fakr:
Custom filters:
ascii: Converts the value to ascii (using Unidecode) (i. e. {{lastname|ascii}})
shuffle: Shuffles the value randomly (i. e. {{lastname|shuffle}})
chance: Gives the value a chance from 0.0 to 1.0 to be returned (i. e. {{firstname|chance(0.9)}} - firstname will be 90% returned, 10% empty)
rjust: Right-justifies the value to the given with (i. e. {{company|rjust(40)}})
ljust: Left-justifies the value to the given with (i. e. {{company|ljust(40)}})
center: Centers the value in width (i. e. {{company|center(40)}})
Custom functions:
translate
uuid4: Returns a new UUIDv4 on every call (i. e. {{uuid4()}})
unixtime: Returns a the current unixtime as float in seconds, (i. e. {{unixtime()}})
Fixed (vocabulary independent) variables:
row: The row (starting from 0) of the current dataset
id: The id or sequence number of the current dataset
guid: The representation of the id in a uuid-like fashion
Release files for fakr 0.0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fakr-0.0.10.tar.gz | 78.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fakr-0.0.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 157.3 kB
Release files / fakr-0.0.10.tar.gz
| Download URL | fakr-0.0.10.tar.gz |
|---|---|
| Size | 78.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92f7b657232dc1ebce5a513382d01d231a2c5b7ab36c79c799ed46c60a6efd1b
|
|
BLAKE2b-256 checksum How to use checksums |
fb1726b93ed726e1f78fafb93b43b5d9d6126117affad6b592d571a33c6f61a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / fakr-0.0.10-py3-none-any.whl
| Download URL | fakr-0.0.10-py3-none-any.whl |
|---|---|
| Size | 78.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1c3eaaae64cd32a9721f174f80238de2b70831258b261d397c0af52ad6147bce
|
|
BLAKE2b-256 checksum How to use checksums |
fd988b5079392032184dd47b262b952aa9b0f4ae48cfae09cf528cf94f3899d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |