OpenFisca-Survey-Manager


NameOpenFisca-Survey-Manager JSON
Version 3.0.1 PyPI version JSON
download
home_pageNone
SummaryA tool for managing survey/administrative data and import them in OpenFisca
upload_time2024-11-29 08:43:18
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords microsimulation tax benefit rac rules-as-code survey data
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OpenFisca Survey Manager

[![Newsletter](https://img.shields.io/badge/newsletter-subscribe!-informational.svg?style=flat)](mailto:contact%40openfisca.org?subject=Subscribe%20to%20your%20newsletter%20%7C%20S'inscrire%20%C3%A0%20votre%20newsletter&body=%5BEnglish%20version%20below%5D%0A%0ABonjour%2C%0A%0AVotre%C2%A0pr%C3%A9sence%C2%A0ici%C2%A0nous%C2%A0ravit%C2%A0!%20%F0%9F%98%83%0A%0AEnvoyez-nous%20cet%20email%20pour%20que%20l'on%20puisse%20vous%20inscrire%20%C3%A0%20la%20newsletter.%20%0A%0AAh%C2%A0!%20Et%20si%20vous%20pouviez%20remplir%20ce%20petit%20questionnaire%2C%20%C3%A7a%20serait%20encore%20mieux%C2%A0!%0Ahttps%3A%2F%2Fgoo.gl%2Fforms%2F45M0VR1TYKD1RGzX2%0A%0AAmiti%C3%A9%2C%0AL%E2%80%99%C3%A9quipe%20OpenFisca%0A%0A%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%20ENGLISH%20VERSION%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%0AHi%2C%20%0A%0AWe're%20glad%20to%20see%20you%20here!%20%F0%9F%98%83%0A%0APlease%20send%20us%20this%20email%2C%20so%20we%20can%20subscribe%20you%20to%20the%20newsletter.%0A%0AAlso%2C%20if%20you%20can%20fill%20out%20this%20short%20survey%2C%20even%20better!%0Ahttps%3A%2F%2Fgoo.gl%2Fforms%2FsOg8K1abhhm441LG2%0A%0ACheers%2C%0AThe%20OpenFisca%20Team)
[![Twitter](https://img.shields.io/badge/twitter-follow%20us!-9cf.svg?style=flat)](https://twitter.com/intent/follow?screen_name=openfisca)
[![Slack](https://img.shields.io/badge/slack-join%20us!-blueviolet.svg?style=flat)](mailto:contact%40openfisca.org?subject=Join%20you%20on%20Slack%20%7C%20Nous%20rejoindre%20sur%20Slack&body=%5BEnglish%20version%20below%5D%0A%0ABonjour%2C%0A%0AVotre%C2%A0pr%C3%A9sence%C2%A0ici%C2%A0nous%C2%A0ravit%C2%A0!%20%F0%9F%98%83%0A%0ARacontez-nous%20un%20peu%20de%20vous%2C%20et%20du%20pourquoi%20de%20votre%20int%C3%A9r%C3%AAt%20de%20rejoindre%20la%20communaut%C3%A9%20OpenFisca%20sur%20Slack.%0A%0AAh%C2%A0!%20Et%20si%20vous%20pouviez%20remplir%20ce%20petit%20questionnaire%2C%20%C3%A7a%20serait%20encore%20mieux%C2%A0!%0Ahttps%3A%2F%2Fgoo.gl%2Fforms%2F45M0VR1TYKD1RGzX2%0A%0AN%E2%80%99oubliez%20pas%20de%20nous%20envoyer%20cet%20email%C2%A0!%20Sinon%2C%20on%20ne%20pourra%20pas%20vous%20contacter%20ni%20vous%20inviter%20sur%20Slack.%0A%0AAmiti%C3%A9%2C%0AL%E2%80%99%C3%A9quipe%20OpenFisca%0A%0A%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%20ENGLISH%20VERSION%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%0AHi%2C%20%0A%0AWe're%20glad%20to%20see%20you%20here!%20%F0%9F%98%83%0A%0APlease%20tell%20us%20a%20bit%20about%20you%20and%20why%20you%20want%20to%20join%20the%20OpenFisca%20community%20on%20Slack.%0A%0AAlso%2C%20if%20you%20can%20fill%20out%20this%20short%20survey%2C%20even%20better!%0Ahttps%3A%2F%2Fgoo.gl%2Fforms%2FsOg8K1abhhm441LG2.%0A%0ADon't%20forget%20to%20send%20us%20this%20email!%20Otherwise%20we%20won't%20be%20able%20to%20contact%20you%20back%2C%20nor%20invite%20you%20on%20Slack.%0A%0ACheers%2C%0AThe%20OpenFisca%20Team)
[![GitHub Actions](https://github.com/openfisca/openfisca-survey-manager/actions/workflows/workflow.yml/badge.svg?branch=master&event=push)](https://github.com/openfisca/openfisca-survey-manager/actions?query=branch%3Amaster)
[![Coveralls](https://img.shields.io/coveralls/github/openfisca/openfisca-survey-manager/master.svg?style=flat)](https://coveralls.io/github/openfisca/openfisca-survey-manager?branch=master)
[![Python](https://img.shields.io/pypi/pyversions/openfisca-survey-manager.svg)](https://pypi.python.org/pypi/openfisca-survey-manager)
[![PyPi](https://img.shields.io/pypi/v/openfisca-survey-manager.svg?style=flat)](https://pypi.python.org/pypi/openfisca-survey-manager)

## [EN] Introduction

[OpenFisca](https://openfisca.org) is a versatile microsimulation free software. You can check the [online documentation](https://openfisca.org/doc/) for more details.

This repository contains the Survey-Manager module, to work with OpenFisca and survey data.

It provides two main features:
* A Python API to access data in [Hierarchical Data Format](https://en.wikipedia.org/wiki/Hierarchical_Data_Format) (HDF) or [Parquet](https://parquet.apache.org/).
* A script that transforms Parquet, SAS, Stata, SPSS, and CSV data files to HDF data files, along with some metadata so they can be used by the Python API. If the format is Parquet, it is kept as is.

> For France survey data, you might find useful information on the next steps in [openfisca-france-data](https://github.com/openfisca/openfisca-france-data) repository.

## [FR] Introduction

[OpenFisca](https://openfisca.org) est un logiciel libre de micro-simulation. Pour plus d'information, vous pouvez consulter la [documentation officielle](https://openfisca.org/doc/).

Ce dépôt contient le module Survey-Manager. Il facilite l'usage d'OpenFisca avec des données d'enquête.

Il fournit deux fonctionnalités principales:
* Une API Python permettant l'accès à des données au format [Hierarchical Data Format](https://fr.wikipedia.org/wiki/Hierarchical_Data_Format) (HDF) ou [Parquet](https://parquet.apache.org/).
* Un script qui tranforme les fichiers de données aux formats SAS, Stata, SPSS, and CSV data files en fichiers de données au format HDF, avec quelques metadonnées leur permettant d'être utilisés par l'API Python. Si le format est Parquet, il est conservé tel quel.

> Si vous disposez de données d'enquête sur la France, le dépôt [openfisca-france-data](https://github.com/openfisca/openfisca-france-data) pourrait être utile à vos prochaines étapes de traitement.

## Environment

OpenFisca-Survey-Manager runs on Python 3.9. More recent versions should work, but are not tested.

## Usage

### Installation

#### Install with PIP

If you're developing your own script or looking to run `OpenFisca-Survey-Manager` without editing it, you don't need to get its source code. It just needs to be known by your environment.
To do so, first, install the package with `pip`:

```shell
pip install --upgrade pip
pip install openfisca-survey-manager
```

This should not display any error and end with:

`Successfully installed [... openfisca-survey-manager-xx.xx.xx ...]`

It comes with `build-collection` command that we will use in the next steps.

> If you want to improve this module, please see the `Development` section below.

#### Install with Conda

Create an anvironment and install openfisca-survey-manager
```
conda create -n survey python=3.9
conda activate survey
conda install -c conda-forge -c openfisca openfisca-survey-manager
```

You are ready to go !

To exit your environment:
```
conda deactivate
```

### Getting the configuration directory path

To be able to use OpenFisca-Survey-Manager, you have to create two configuration files:
* `raw_data.ini`,
* and `config.ini`.

To know where to copy them to, use the following command:

```shell
build-collection --help
```

You should get the following result.

```shell
usage: build-collection [-h] -c COLLECTION [-d] [-m] [-p PATH] [-s SURVEY]
                        [-v]

optional arguments:
  -h, --help            show this help message and exit
  -c COLLECTION, --collection COLLECTION
                        name of collection to build or update
  -d, --replace-data    erase existing survey data HDF5 file (instead of
                        failing when HDF5 file already exists)
  -m, --replace-metadata
                        erase existing collection metadata JSON file (instead
                        of just adding new surveys)
  -p PATH, --path PATH  path to the config files directory (default =
                        /your/path/.config/openfisca-survey-manager)
  -s SURVEY, --survey SURVEY
                        name of survey to build or update (default = all)
  -v, --verbose         increase output verbosity
```

Take note of the default configuration directory path in `-p PATH, --path PATH` option's description. This is the directory where you will set your `raw_data.ini` and `config.ini` files. In this example, it is `/Users/you/.config/openfisca-survey-manager`.

> If you want to use a different path, you can pass the `--path /another/path` option to `build-collection`. This feature is still experimental though.

### Editing the config files

Configuration files are INI files (text files).

The `raw_data.ini` lists your input surveys while `config.ini` specifies the paths to SurveyManager outputs.

> `raw_data.ini` and `config.ini` must not be committed (they are already ignored by [`.gitignore`](.gitignore)).

#### raw_data.ini, for inputs configuration

To initialise your `raw_data.ini` file, you can follow these steps:

  1. Copy the template file [raw_data_template.ini](openfisca_survey_manager/config_files_templates/raw_data_template.ini) to the configuration directory path you identified in the previous step and rename it to `raw_data.ini`.
  Ex: `/your/path/.config/openfisca-survey-manager/raw_data.ini`

  2. Edit the latter by adding a section title for your survey.
  For example, if you name your survey `housing_survey`, you should get a line with:
  ```ini
  [housing_survey]
  ```

  3. Add a reference to the location of your raw data **directory** (SAS, stata DTA files, SPSS, CSV files).
  For paths in Windows, use `/` instead of `\` to separate folders.
  You do not need to put quotes, even when the path name contains spaces.

  Your file should look like this:

  ```ini
  [housing_survey]

  2014 = /path/to/your/raw/data/HOUSING_2014
  ```

You can also set multiple surveys as follows:

```ini
[revenue_survey]

2014 = /path/to/your/raw/data/REVENUE_2014
2015 = /path/to/your/raw/data/REVENUE_2015
2016 = /path/to/your/raw/data/REVENUE_2016

[housing_survey]

2014 = /path/to/your/raw/data/HOUSING_2014
```

#### config.ini, for outputs configuration

To initilalise your `config.ini` file:

  1. Copy its template file [config_template.ini](openfisca_survey_manager/config_files_templates/config_template.ini) to your configuration directory and rename it to `config.ini`.
  Ex: `/your/path/.config/openfisca-survey-manager/config.ini`.

  2. Define a `collections_directory` path where the SurveyManager will generate your survey inputs and outputs JSON description.
  Ex: `/.../openfisca-survey-manager/transformed_housing_survey`
  For a `housing_survey`, you will get a `/.../openfisca-survey-manager/transformed_housing_survey/housing_survey.json` file.

  3. Define an `output_directory` where the generated HDF file will be registered.
    This directory could be a sub-directory of your `collections_directory`.

  4. Define a `tmp_directory` that will store temporay calculation results. Its content will be deleted at the end of the calculation.
    This directory could be a sub-directory of your `collections_directory`.

Your `config.ini` file should look similar to this:

  ```ini
  [collections]

  collections_directory = /path/to/your/collections/directory

  [data]

  output_directory = /path/to/your/data/output/directory
  tmp_directory = /path/to/your/data/tmp/directory
  ```

> Make sure those directories exist, otherwise the script will fail.

### Building the HDF5 files

This step will read your configuration files and you survey data and generate a HDF5 file (`.h5`) for your survey.
To build the HDF5 files, we'll use the [`build-collection`](openfisca_survey_manager/scripts/build_collection.py) script.

Here is an example for one survey with one serie: our `housing_survey` that knows only 2014 serie. We call our survey as a collection (with `-c` option) and build the HDF5 file with this command:

```shell
build-collection -c housing_survey -d -m -v
```

`-d -m` options put you on the safe side as they remove previous outputs if they exist.

It will generate:
* A `housing_survey.json` listing a `housing_survey_2014` survey with both:
  * your input `tables` and your input file paths in an `informations` key,
  * the transformed survey path in a `hdf5_file_path` key.
* Your transformed survey in a `housing_survey_2014.h5` file.

#### build-collection, what else?

As `build-collection --help` shows, other options exist. Here are other usage examples.

If you have multiple series of one survey like the `revenue_survey`, you can run the specific `2015` serie with:

```shell
build-collection -c revenue_survey -s 2015 -d -m -v
```

Or if you want to specify a different configuration directory path:

```shell
build-collection -p /another/path -c housing_survey -s 2014 -d -m -v
```

> The `--path /another/path` option is still experimental though.

It should work. If it doesn't, please do not hesitate to [open an issue](https://github.com/openfisca/openfisca-survey-manager/issues/new).

### Parquet files

Parquet files could be used as input files. They will not be converted to HDF5. As Parquet files can only contains one table, we add a `"parquet_file"` key to each table in a survey. This key contains the path to the Parquet file, or the folder containing many parquet files for the same table.

If using folder you have to name your files with the following pattern: `some_name_-<number>.parquet` and keep only the files for the same table in the same folder.

If a single file contains all the table, you can have many files for different tables in the same folder.

## Development

If you want to contribute to OpenFisca-Survey-Manager, please be welcomed! To install it locally in development mode:

```shell
git clone https://github.com/openfisca/openfisca-survey-manager.git
cd openfisca-survey-manager
make install
```

## Testing

To run the entire test suite:

```sh
make test
```

To run the entire test suite with the same config as in Continuous Integration (CI):

```sh
CI=True make test
```

## Style

This repository adheres to a certain coding style, and we invite you to follow it for your contributions to be integrated promptly.

To run the style checker:

```sh
make check-style
```

To automatically style-format your code changes:

```sh
make format-style
```

To automatically style-format your code changes each time you commit:

```sh
touch .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

tee -a .git/hooks/pre-commit << END
#!/bin/sh
#
# Automatically format your code before committing.
exec make format-style
END
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "OpenFisca-Survey-Manager",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "microsimulation, tax, benefit, rac, rules-as-code, survey, data",
    "author": null,
    "author_email": "OpenFisca Team <contact@openfisca.fr>",
    "download_url": "https://files.pythonhosted.org/packages/e1/48/885b74c25a81399080fd83fc51b928fc4ca0aeff85b5051657e82c6ba90b/openfisca_survey_manager-3.0.1.tar.gz",
    "platform": null,
    "description": "# OpenFisca Survey Manager\n\n[![Newsletter](https://img.shields.io/badge/newsletter-subscribe!-informational.svg?style=flat)](mailto:contact%40openfisca.org?subject=Subscribe%20to%20your%20newsletter%20%7C%20S'inscrire%20%C3%A0%20votre%20newsletter&body=%5BEnglish%20version%20below%5D%0A%0ABonjour%2C%0A%0AVotre%C2%A0pr%C3%A9sence%C2%A0ici%C2%A0nous%C2%A0ravit%C2%A0!%20%F0%9F%98%83%0A%0AEnvoyez-nous%20cet%20email%20pour%20que%20l'on%20puisse%20vous%20inscrire%20%C3%A0%20la%20newsletter.%20%0A%0AAh%C2%A0!%20Et%20si%20vous%20pouviez%20remplir%20ce%20petit%20questionnaire%2C%20%C3%A7a%20serait%20encore%20mieux%C2%A0!%0Ahttps%3A%2F%2Fgoo.gl%2Fforms%2F45M0VR1TYKD1RGzX2%0A%0AAmiti%C3%A9%2C%0AL%E2%80%99%C3%A9quipe%20OpenFisca%0A%0A%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%20ENGLISH%20VERSION%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%0AHi%2C%20%0A%0AWe're%20glad%20to%20see%20you%20here!%20%F0%9F%98%83%0A%0APlease%20send%20us%20this%20email%2C%20so%20we%20can%20subscribe%20you%20to%20the%20newsletter.%0A%0AAlso%2C%20if%20you%20can%20fill%20out%20this%20short%20survey%2C%20even%20better!%0Ahttps%3A%2F%2Fgoo.gl%2Fforms%2FsOg8K1abhhm441LG2%0A%0ACheers%2C%0AThe%20OpenFisca%20Team)\n[![Twitter](https://img.shields.io/badge/twitter-follow%20us!-9cf.svg?style=flat)](https://twitter.com/intent/follow?screen_name=openfisca)\n[![Slack](https://img.shields.io/badge/slack-join%20us!-blueviolet.svg?style=flat)](mailto:contact%40openfisca.org?subject=Join%20you%20on%20Slack%20%7C%20Nous%20rejoindre%20sur%20Slack&body=%5BEnglish%20version%20below%5D%0A%0ABonjour%2C%0A%0AVotre%C2%A0pr%C3%A9sence%C2%A0ici%C2%A0nous%C2%A0ravit%C2%A0!%20%F0%9F%98%83%0A%0ARacontez-nous%20un%20peu%20de%20vous%2C%20et%20du%20pourquoi%20de%20votre%20int%C3%A9r%C3%AAt%20de%20rejoindre%20la%20communaut%C3%A9%20OpenFisca%20sur%20Slack.%0A%0AAh%C2%A0!%20Et%20si%20vous%20pouviez%20remplir%20ce%20petit%20questionnaire%2C%20%C3%A7a%20serait%20encore%20mieux%C2%A0!%0Ahttps%3A%2F%2Fgoo.gl%2Fforms%2F45M0VR1TYKD1RGzX2%0A%0AN%E2%80%99oubliez%20pas%20de%20nous%20envoyer%20cet%20email%C2%A0!%20Sinon%2C%20on%20ne%20pourra%20pas%20vous%20contacter%20ni%20vous%20inviter%20sur%20Slack.%0A%0AAmiti%C3%A9%2C%0AL%E2%80%99%C3%A9quipe%20OpenFisca%0A%0A%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%20ENGLISH%20VERSION%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%0AHi%2C%20%0A%0AWe're%20glad%20to%20see%20you%20here!%20%F0%9F%98%83%0A%0APlease%20tell%20us%20a%20bit%20about%20you%20and%20why%20you%20want%20to%20join%20the%20OpenFisca%20community%20on%20Slack.%0A%0AAlso%2C%20if%20you%20can%20fill%20out%20this%20short%20survey%2C%20even%20better!%0Ahttps%3A%2F%2Fgoo.gl%2Fforms%2FsOg8K1abhhm441LG2.%0A%0ADon't%20forget%20to%20send%20us%20this%20email!%20Otherwise%20we%20won't%20be%20able%20to%20contact%20you%20back%2C%20nor%20invite%20you%20on%20Slack.%0A%0ACheers%2C%0AThe%20OpenFisca%20Team)\n[![GitHub Actions](https://github.com/openfisca/openfisca-survey-manager/actions/workflows/workflow.yml/badge.svg?branch=master&event=push)](https://github.com/openfisca/openfisca-survey-manager/actions?query=branch%3Amaster)\n[![Coveralls](https://img.shields.io/coveralls/github/openfisca/openfisca-survey-manager/master.svg?style=flat)](https://coveralls.io/github/openfisca/openfisca-survey-manager?branch=master)\n[![Python](https://img.shields.io/pypi/pyversions/openfisca-survey-manager.svg)](https://pypi.python.org/pypi/openfisca-survey-manager)\n[![PyPi](https://img.shields.io/pypi/v/openfisca-survey-manager.svg?style=flat)](https://pypi.python.org/pypi/openfisca-survey-manager)\n\n## [EN] Introduction\n\n[OpenFisca](https://openfisca.org) is a versatile microsimulation free software. You can check the [online documentation](https://openfisca.org/doc/) for more details.\n\nThis repository contains the Survey-Manager module, to work with OpenFisca and survey data.\n\nIt provides two main features:\n* A Python API to access data in [Hierarchical Data Format](https://en.wikipedia.org/wiki/Hierarchical_Data_Format) (HDF) or [Parquet](https://parquet.apache.org/).\n* A script that transforms Parquet, SAS, Stata, SPSS, and CSV data files to HDF data files, along with some metadata so they can be used by the Python API. If the format is Parquet, it is kept as is.\n\n> For France survey data, you might find useful information on the next steps in [openfisca-france-data](https://github.com/openfisca/openfisca-france-data) repository.\n\n## [FR] Introduction\n\n[OpenFisca](https://openfisca.org) est un logiciel libre de micro-simulation. Pour plus d'information, vous pouvez consulter la [documentation officielle](https://openfisca.org/doc/).\n\nCe d\u00e9p\u00f4t contient le module Survey-Manager. Il facilite l'usage d'OpenFisca avec des donn\u00e9es d'enqu\u00eate.\n\nIl fournit deux fonctionnalit\u00e9s principales:\n* Une API Python permettant l'acc\u00e8s \u00e0 des donn\u00e9es au format [Hierarchical Data Format](https://fr.wikipedia.org/wiki/Hierarchical_Data_Format) (HDF) ou [Parquet](https://parquet.apache.org/).\n* Un script qui tranforme les fichiers de donn\u00e9es aux formats SAS, Stata, SPSS, and CSV data files en fichiers de donn\u00e9es au format HDF, avec quelques metadonn\u00e9es leur permettant d'\u00eatre utilis\u00e9s par l'API Python. Si le format est Parquet, il est conserv\u00e9 tel quel.\n\n> Si vous disposez de donn\u00e9es d'enqu\u00eate sur la France, le d\u00e9p\u00f4t [openfisca-france-data](https://github.com/openfisca/openfisca-france-data) pourrait \u00eatre utile \u00e0 vos prochaines \u00e9tapes de traitement.\n\n## Environment\n\nOpenFisca-Survey-Manager runs on Python 3.9. More recent versions should work, but are not tested.\n\n## Usage\n\n### Installation\n\n#### Install with PIP\n\nIf you're developing your own script or looking to run `OpenFisca-Survey-Manager` without editing it, you don't need to get its source code. It just needs to be known by your environment.\nTo do so, first, install the package with `pip`:\n\n```shell\npip install --upgrade pip\npip install openfisca-survey-manager\n```\n\nThis should not display any error and end with:\n\n`Successfully installed [... openfisca-survey-manager-xx.xx.xx ...]`\n\nIt comes with `build-collection` command that we will use in the next steps.\n\n> If you want to improve this module, please see the `Development` section below.\n\n#### Install with Conda\n\nCreate an anvironment and install openfisca-survey-manager\n```\nconda create -n survey python=3.9\nconda activate survey\nconda install -c conda-forge -c openfisca openfisca-survey-manager\n```\n\nYou are ready to go !\n\nTo exit your environment:\n```\nconda deactivate\n```\n\n### Getting the configuration directory path\n\nTo be able to use OpenFisca-Survey-Manager, you have to create two configuration files:\n* `raw_data.ini`,\n* and `config.ini`.\n\nTo know where to copy them to, use the following command:\n\n```shell\nbuild-collection --help\n```\n\nYou should get the following result.\n\n```shell\nusage: build-collection [-h] -c COLLECTION [-d] [-m] [-p PATH] [-s SURVEY]\n                        [-v]\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -c COLLECTION, --collection COLLECTION\n                        name of collection to build or update\n  -d, --replace-data    erase existing survey data HDF5 file (instead of\n                        failing when HDF5 file already exists)\n  -m, --replace-metadata\n                        erase existing collection metadata JSON file (instead\n                        of just adding new surveys)\n  -p PATH, --path PATH  path to the config files directory (default =\n                        /your/path/.config/openfisca-survey-manager)\n  -s SURVEY, --survey SURVEY\n                        name of survey to build or update (default = all)\n  -v, --verbose         increase output verbosity\n```\n\nTake note of the default configuration directory path in `-p PATH, --path PATH` option's description. This is the directory where you will set your `raw_data.ini` and `config.ini` files. In this example, it is `/Users/you/.config/openfisca-survey-manager`.\n\n> If you want to use a different path, you can pass the `--path /another/path` option to `build-collection`. This feature is still experimental though.\n\n### Editing the config files\n\nConfiguration files are INI files (text files).\n\nThe `raw_data.ini` lists your input surveys while `config.ini` specifies the paths to SurveyManager outputs.\n\n> `raw_data.ini` and `config.ini` must not be committed (they are already ignored by [`.gitignore`](.gitignore)).\n\n#### raw_data.ini, for inputs configuration\n\nTo initialise your `raw_data.ini` file, you can follow these steps:\n\n  1. Copy the template file [raw_data_template.ini](openfisca_survey_manager/config_files_templates/raw_data_template.ini) to the configuration directory path you identified in the previous step and rename it to `raw_data.ini`.\n  Ex: `/your/path/.config/openfisca-survey-manager/raw_data.ini`\n\n  2. Edit the latter by adding a section title for your survey.\n  For example, if you name your survey `housing_survey`, you should get a line with:\n  ```ini\n  [housing_survey]\n  ```\n\n  3. Add a reference to the location of your raw data **directory** (SAS, stata DTA files, SPSS, CSV files).\n  For paths in Windows, use `/` instead of `\\` to separate folders.\n  You do not need to put quotes, even when the path name contains spaces.\n\n  Your file should look like this:\n\n  ```ini\n  [housing_survey]\n\n  2014 = /path/to/your/raw/data/HOUSING_2014\n  ```\n\nYou can also set multiple surveys as follows:\n\n```ini\n[revenue_survey]\n\n2014 = /path/to/your/raw/data/REVENUE_2014\n2015 = /path/to/your/raw/data/REVENUE_2015\n2016 = /path/to/your/raw/data/REVENUE_2016\n\n[housing_survey]\n\n2014 = /path/to/your/raw/data/HOUSING_2014\n```\n\n#### config.ini, for outputs configuration\n\nTo initilalise your `config.ini` file:\n\n  1. Copy its template file [config_template.ini](openfisca_survey_manager/config_files_templates/config_template.ini) to your configuration directory and rename it to `config.ini`.\n  Ex: `/your/path/.config/openfisca-survey-manager/config.ini`.\n\n  2. Define a `collections_directory` path where the SurveyManager will generate your survey inputs and outputs JSON description.\n  Ex: `/.../openfisca-survey-manager/transformed_housing_survey`\n  For a `housing_survey`, you will get a `/.../openfisca-survey-manager/transformed_housing_survey/housing_survey.json` file.\n\n  3. Define an `output_directory` where the generated HDF file will be registered.\n    This directory could be a sub-directory of your `collections_directory`.\n\n  4. Define a `tmp_directory` that will store temporay calculation results. Its content will be deleted at the end of the calculation.\n    This directory could be a sub-directory of your `collections_directory`.\n\nYour `config.ini` file should look similar to this:\n\n  ```ini\n  [collections]\n\n  collections_directory = /path/to/your/collections/directory\n\n  [data]\n\n  output_directory = /path/to/your/data/output/directory\n  tmp_directory = /path/to/your/data/tmp/directory\n  ```\n\n> Make sure those directories exist, otherwise the script will fail.\n\n### Building the HDF5 files\n\nThis step will read your configuration files and you survey data and generate a HDF5 file (`.h5`) for your survey.\nTo build the HDF5 files, we'll use the [`build-collection`](openfisca_survey_manager/scripts/build_collection.py) script.\n\nHere is an example for one survey with one serie: our `housing_survey` that knows only 2014 serie. We call our survey as a collection (with `-c` option) and build the HDF5 file with this command:\n\n```shell\nbuild-collection -c housing_survey -d -m -v\n```\n\n`-d -m` options put you on the safe side as they remove previous outputs if they exist.\n\nIt will generate:\n* A `housing_survey.json` listing a `housing_survey_2014` survey with both:\n  * your input `tables` and your input file paths in an `informations` key,\n  * the transformed survey path in a `hdf5_file_path` key.\n* Your transformed survey in a `housing_survey_2014.h5` file.\n\n#### build-collection, what else?\n\nAs `build-collection --help` shows, other options exist. Here are other usage examples.\n\nIf you have multiple series of one survey like the `revenue_survey`, you can run the specific `2015` serie with:\n\n```shell\nbuild-collection -c revenue_survey -s 2015 -d -m -v\n```\n\nOr if you want to specify a different configuration directory path:\n\n```shell\nbuild-collection -p /another/path -c housing_survey -s 2014 -d -m -v\n```\n\n> The `--path /another/path` option is still experimental though.\n\nIt should work. If it doesn't, please do not hesitate to [open an issue](https://github.com/openfisca/openfisca-survey-manager/issues/new).\n\n### Parquet files\n\nParquet files could be used as input files. They will not be converted to HDF5. As Parquet files can only contains one table, we add a `\"parquet_file\"` key to each table in a survey. This key contains the path to the Parquet file, or the folder containing many parquet files for the same table.\n\nIf using folder you have to name your files with the following pattern: `some_name_-<number>.parquet` and keep only the files for the same table in the same folder.\n\nIf a single file contains all the table, you can have many files for different tables in the same folder.\n\n## Development\n\nIf you want to contribute to OpenFisca-Survey-Manager, please be welcomed! To install it locally in development mode:\n\n```shell\ngit clone https://github.com/openfisca/openfisca-survey-manager.git\ncd openfisca-survey-manager\nmake install\n```\n\n## Testing\n\nTo run the entire test suite:\n\n```sh\nmake test\n```\n\nTo run the entire test suite with the same config as in Continuous Integration (CI):\n\n```sh\nCI=True make test\n```\n\n## Style\n\nThis repository adheres to a certain coding style, and we invite you to follow it for your contributions to be integrated promptly.\n\nTo run the style checker:\n\n```sh\nmake check-style\n```\n\nTo automatically style-format your code changes:\n\n```sh\nmake format-style\n```\n\nTo automatically style-format your code changes each time you commit:\n\n```sh\ntouch .git/hooks/pre-commit\nchmod +x .git/hooks/pre-commit\n\ntee -a .git/hooks/pre-commit << END\n#!/bin/sh\n#\n# Automatically format your code before committing.\nexec make format-style\nEND\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A tool for managing survey/administrative data and import them in OpenFisca",
    "version": "3.0.1",
    "project_urls": {
        "Changelog": "https://github.com/openfisca/openfisca-survey-manager/blob/main/CHANGELOG.md",
        "Homepage": "https://github.com/openfisca/openfisca-survey-manager",
        "Issues": "https://github.com/openfisca/openfisca-survey-manager/issues",
        "Repository": "https://github.com/openfisca/openfisca-survey-manager"
    },
    "split_keywords": [
        "microsimulation",
        " tax",
        " benefit",
        " rac",
        " rules-as-code",
        " survey",
        " data"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bef5f564f999c52e1abed2f09a9cbbd4483f57e5dfd7c9a7435186918156de7b",
                "md5": "5ba51635b1dea72432facf0c263d67b0",
                "sha256": "927ce40e17fd988340c8dc4a8c833d78fbf387701704e286bf4323bf09fe6c94"
            },
            "downloads": -1,
            "filename": "OpenFisca_Survey_Manager-3.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5ba51635b1dea72432facf0c263d67b0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 161725,
            "upload_time": "2024-11-29T08:43:10",
            "upload_time_iso_8601": "2024-11-29T08:43:10.783718Z",
            "url": "https://files.pythonhosted.org/packages/be/f5/f564f999c52e1abed2f09a9cbbd4483f57e5dfd7c9a7435186918156de7b/OpenFisca_Survey_Manager-3.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e148885b74c25a81399080fd83fc51b928fc4ca0aeff85b5051657e82c6ba90b",
                "md5": "bbf341c3169319aa39da340f370b07b0",
                "sha256": "1ba5722cfb1351d91f5b83418ac843c21313327440a06db97d213e5f0c648c7c"
            },
            "downloads": -1,
            "filename": "openfisca_survey_manager-3.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "bbf341c3169319aa39da340f370b07b0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 159449,
            "upload_time": "2024-11-29T08:43:18",
            "upload_time_iso_8601": "2024-11-29T08:43:18.316864Z",
            "url": "https://files.pythonhosted.org/packages/e1/48/885b74c25a81399080fd83fc51b928fc4ca0aeff85b5051657e82c6ba90b/openfisca_survey_manager-3.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-29 08:43:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "openfisca",
    "github_project": "openfisca-survey-manager",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "openfisca-survey-manager"
}
        
Elapsed time: 9.24818s