Metadata-Version: 2.1
Name: csv-normalizer
Version: 0.1.2
Summary: csv normalize to have always same output csv
Home-page: https://github.com/CoffeeITWorks/csv_normalizer
Author: Pablo Estigarribia
Author-email: pablodav@gmail.com
License: MIT
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: System Administrators
Classifier: Topic :: Utilities
Classifier: Intended Audience :: Telecommunications Industry
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Description-Content-Type: text/markdown
Requires-Dist: pandas (>=0.24.2)

****
Info
****

This is just a simple script that ensures all your .csv files have always same columns and in the same order. Probably
one of the most common issues with .csv files: 

* Some system doesn't respects the columns orders
* Some system doesn't adds a column when there is no data for such column

The script/program resolves both cases in a simple way, process:

Process: 
![alt text](csv_normalizer_process.png "Diagram process")

Normalize: ensure order of columns is always same, add missing columns with empty data.

Example, you have a meteorologic station that should always generate a .csv with the following columns

    Temperature, Humidity, Radiation, Wind, Wind gust

But sometimes one of the sensors doesn't have data and instead of sending all the columns to the .csv it generates partial .csv

    Temperature, Humidity, Wind, Wind gust

In this case the software that process the .csv could fail, so you can use the csv_normalizer to ensure the .csv file is always

    Temperature, Humidity, Radiation, Wind, Wind gust

In this case the csv_normalizer will add the missing column with empty data.
Also the csv_normalizer will ensure the order of the columns is always the same.

Returns always a dict/json like, with the 'ok' or 'fail' list of processed files.
examples:

```sh
{'failed': [],
'ok': [
    {'export_path': 'C:\\temp\\csv_export\\business-financial-data-jun-2021-quarter.csv',
        'import_path': 'C:\\temp\\csv_import\\business-financial-data-jun-2021-quarter.csv'}
        ]
}

# Example when nothing was processed:
{'failed': [],
'ok': []}
```

***************
Example config:
***************

```ini
[common]
csv_import_folder = C:/temp/csv_import
csv_export_folder = C:/temp/csv_export
csv_export_headers = 'Series_reference', 'Period', 'ELEE'
csv_delimiter = ;
csv_encoding = utf-8
```

*****
Usage
*****

```sh
usage: csv_normalizer [-h] [-c [CONFIG_INI]] [--version [VERSION]] [--no_rename [NO_RENAME_OLD]] [--write_config]

optional arguments:
-h, --help            show this help message and exit
-c [CONFIG_INI],      --config_ini [CONFIG_INI]
                        csv_normalizer ini configuration file
--version [VERSION]   Print version and exit
--no_rename [NO_RENAME_OLD]
                        Do not rename to .old the original file
--write_config        Write configuration with default values, useful to get a config file to modify
```

Example usage on Linux

    csv_normalizer -c .\csv_normalizer.ini

On windows:

    csv_normalizer.exe -c .\csv_normalizer.ini

Adding option to not rename the original files:

    csv_normalizer -c .\csv_normalizer.ini --no_rename

By default csv_normalizer will rename the original files to .old so if you run the program again, it will not process same files again.

*******
Install
*******

```sh
pip install --user csv_normalizer

# or for root account

pip install csv_normalizer
```

******
Author
******

Author: Pablo Estigarribia <pablodav at gmail dot com>

Project site: https://github.com/CoffeeITWorks/csv_normalizer


