Metadata-Version: 2.2
Name: curedcolumns
Version: 0.1.3
Summary: CUREd+ metadata tool: generates a list of all the columns in every table in the database.
License: MIT License
        
        Copyright (c) 2024 Data Connect
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://www.sheffield.ac.uk/data-connect
Project-URL: Bug_Tracker, https://github.com/CUREd-Plus/curedcolumns/issues
Project-URL: Documentation, https://github.com/CUREd-Plus/curedcolumns/blob/main/README.md
Project-URL: Repository, https://github.com/CUREd-Plus/curedcolumns
Project-URL: Changelog, https://github.com/CUREd-Plus/curedcolumns/releases
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: boto3==1.*
Requires-Dist: pyarrow==16.*
Requires-Dist: boto3-type-annotations==0.*
Provides-Extra: test
Requires-Dist: pytest==8.*; extra == "test"
Requires-Dist: moto[s3]==5.*; extra == "test"

[![Tests passing](https://github.com/CUREd-Plus/curedcolumns/actions/workflows/test.yml/badge.svg)](https://github.com/CUREd-Plus/curedcolumns/actions/workflows/test.yml)

# CUREd+ metadata generator

The CUREd+ metadata generator tool generates a list of all the columns in every table in the database.

The data in the target bucket must be arranged in the following directory structure: `<data_set_id>/<table_id>/data/*.parquet`

This script will generate a CSV file with the following columns:

 * `data_set_id`
 * `table_id`
 * `column_name`
 * `data_type`

# Installation

Ensure [Python](https://www.python.org/) is installed.
(See [this tutorial](https://www.digitalocean.com/community/tutorials/install-python-windows-10).)

Install [AWS command-line interface (CLI)](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html).
[Configure your access key](https://docs.aws.amazon.com/cli/v1/userguide/cli-chap-configure.html) using the
[`aws configure`](https://docs.aws.amazon.com/cli/latest/reference/configure/) command.

Install this package using the [Python package manager](https://pip.pypa.io/en/stable/):

```bash
pip install curedcolumns
```

# Usage

The basic usage of this app is to specify the AWS CLI profile and the bucket name you want to inspect.

```bash
curedcolumns --profile $AWS_PROFILE $AWS_BUCKET --output $OUTPUT_FILE
```

You should create an AWS profile using the [`aws configure`](https://docs.aws.amazon.com/cli/v1/userguide/cli-chap-configure.html) command.

```bash
aws configure --profile $AWS_PROFILE
```

To view the command line options:

```bash
$ curedcolumns --help 
usage: curedcolumns [-h] [-v] [--version] [-l LOGLEVEL] [--prefix PREFIX] [--no-sign-request] [--profile PROFILE] [-d DELIMITER] [-o OUTPUT] [-f] bucket

List all the field names for all the data sets in a bucket on AWS S3 object storage and display the metadata in CSV format. This assumes a folder structure in this layout: <data_set_id>/<table_id>/data/*.parquet

positional arguments:
  bucket                S3 bucket location URI

options:
  -h, --help            show this help message and exit
  -v, --verbose
  --version             Show the version number of this tool
  -l LOGLEVEL, --loglevel LOGLEVEL
  --prefix PREFIX       Limits the response to keys that begin with the specified prefix.
  --no-sign-request
  --profile PROFILE     AWS profile to use
  -d DELIMITER, --delimiter DELIMITER
                        Column separator character
  -o OUTPUT, --output OUTPUT
                        Output file path. Default: screen
  -f, --force           Overwrite output file if it already exists
```

## Example

Use the [AWS CLI](https://docs.aws.amazon.com/cli/v1/userguide/) profile named "clean"

```bash
curedcolumns --profile clean s3://my_bucket.aws.com
```

# Development

See [CONTRIBUTING.md](https://github.com/CUREd-Plus/curedcolumns/blob/main/CONTRIBUTING.md).
