Skip to main content

datanonymizer

Anonymizer tool for datasets such CSV files.

To generate fake data, you can choose between two excelent generators:

Install

Using pip:

pip install datanonymizer

Using mimesis instead of the default Faker:

pip install datanonymizer[mimesis]

Or from source:

git clone https://github.com/fgmacedo/datanonymizer
cd datanonymizer
python setup.py install

Usage

Pass your data through stdin and get it back anonymized on stdout.

cat input_file.csv | datanonymizer >output_file.csv

Using a config file to declare conversions and generators for the required fields:

cat input_file.csv | datanonymizer --config ./dataset_anon_config.yml >output_file.csv

Please see examples folder for a small demo:

cat examples/small.csv | python -m datanonymizer -i --config examples/small_faker.yml --seed my_seed >examples/small_anonymized_using_faker.csv

Optional arguments:

-h, --help            show this help message and exit
-l LANGUAGE, --language LANGUAGE
                      Language used by the Generator
-di DELIMITER_INPUT, --delimiter_input DELIMITER_INPUT
                      CSV delimiter
-do DELIMITER_OUTPUT, --delimiter_output DELIMITER_OUTPUT
                      CSV delimiter
-i, --ignore_errors   Continue on errors
--head HEAD           Outputs only the first <HEAD> lines
-g {faker,mimesis}, --generator {faker,mimesis}
                      Generator library to be used for fake data
--seed SEED           Seed for the pseudo random generator providers
--config CONFIG       Configuration file

Config file

You’l need a configuration file to setup transformations for each dataset.

This file is a simple yaml where you can configure fields.

Field names should match the column name declared into the CSV input file.

---
fields:
  Task ID:
    omit: true
  Location:
    conversions:
      - fn: coords_to_h3
        kwargs:
          resolution: 8
  Client Address:
    conversions:
      - fn: has_value
    rename: has_address
  Company Name:
    generator:
      provider: business.company
    rename: company
  Invoice ID:
    generator:
      provider: person.identifier
      kwargs:
        mask: "#######"
    rename: invoice

Generators

The generatos clause depends of the library you choose to provide fake data.

You can use any generator available at the generic API from Faker or mimesis.

For example, if you wanna mimic data with company names:

  • Faker

    ---
    fields:
      Company Name:
        generator:
          provider: company
  • Mimesis

    ---
    fields:
      Company Name:
        generator:
          provider: business.company

But you can replace the real names by names of fruits (using Mimesis) or any other provider:

---
fields:
  Company Name:
    generator:
      provider: food.fruit

Or generate random integers to replace real IDs:

  • Faker

    ---
    fields:
      ID:
        generator:
          provider: pyint
          kwargs:
            min_value: 1
            max_value: 15_000_000
  • Mimesis

    ---
    fields:
      ID:
        generator:
          provider: person.identifier
          kwargs:
            mask: "#######"

Conversions

You can apply any pre-configured conversion functions available.

  • coords_to_h3

  • has_value

Metadata

Release files for datanonymizer 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datanonymizer 0.2
File Size Uploaded Provenance
datanonymizer-0.2.tar.gz 7.0 kB Without provenance Details

Release files / datanonymizer-0.2.tar.gz

Download URL datanonymizer-0.2.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fb12000901ec0cdf3fae35934f061ca09c5e86f4f1816a698450364480c73cb2
BLAKE2b-256 checksum
How to use checksums
8321d005ba263aa954decf5291dc3c10f761439534f0989ec3b81b816c5bfad5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

Security for datanonymizer 0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page