Skip to main content

A library for validating tsv files before uploading them to the Musiio API

Project description

Musiio Validate TSV

This library helps to validate tsv files before uploading them to the Musiio Search API (https://search.musiio.com/api#postIndex).

Installation

pip install musiio_validate_tsv

Basic Usage

from musiio_validate_tsv.validate_tsv import ValidateTSV
validate_tsv = ValidateTSV()
errors, processed_rows = validate_tsv.process_tsv(tsv_file_path="tracks_list.tsv")

Output Parameters

Field Name Type Description
processed_rows array Contains a list of dictionaries each containing a mapping of the column names to the corresponding row data. Set to None if there are errors.
errors array Contains a list of dictionaries each containing a mapping indicating the row number and the error associated with that row. Set to None if there are no errors.

Output Example

processed_rows = [
    {
            "customer_track_id": "fake_id",
            "customer_filename": "fake_filename"
    }
]

errors = [
    {
        "row_number": 1,
        "error_message": "Missing required field : audio_url"
    }
]

Advanced Usage

Custom Fields

This is for specifying custom column added in the tsv. The format is as follows:

custom_fields = {
        "field_name": {
            "required": "True", # Boolean
            "internal_id": "internal_field_id", # String
            "type": "int" # string which can be int|string|date|float
        }
}

Example

from musiio_validate_tsv.validate_tsv import ValidateTSV
validate_tsv = ValidateTSV()
errors, processed_rows = validate_tsv.process_tsv(
            tsv_file_path="data_with_custom_fields.tsv",
            custom_fields={
                "region code": {
                    "required": False,
                    "internal_id": "region_code",
                    "type": "string"
                },
                "release date": {
                    "required": False,
                    "internal_id": "release date",
                    "type": "date"
                }
            })

Sample Output

The custom field values get put under a special key called custom_properties

processed_rows = [
    {
        "customer_track_id": "fake_id",
        "customer_filename": "fake_filename",
        "custom_properties": {
            "region_code": ["eu"],
            "release date": ["2012-12-05"]
        }
    }
]

Max Errors

This is to limit number of error rows returned by the tsv

Example

from musiio_validate_tsv.validate_tsv import ValidateTSV
validate_tsv = ValidateTSV()
errors, processed_rows = validate_tsv.process_tsv(tsv_file_path="tests/test_data/process_tsv_invalid_max_error_rows.tsv",
                                                  max_errors=5)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

musiio_validate_tsv-1.0.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

musiio_validate_tsv-1.0.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file musiio_validate_tsv-1.0.2.tar.gz.

File metadata

  • Download URL: musiio_validate_tsv-1.0.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for musiio_validate_tsv-1.0.2.tar.gz
Algorithm Hash digest
SHA256 866144ee279ec9357441a80b5036ca5aea58903113c6a927f391601852fb660e
MD5 211df7134ecead316fb24d7d74e5a316
BLAKE2b-256 71ca6fe9bafb483acea2b7f4f90c8cb0c758759dadf17865046a022488ca2d1c

See more details on using hashes here.

File details

Details for the file musiio_validate_tsv-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: musiio_validate_tsv-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for musiio_validate_tsv-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 942099e383acfbdaef4bf115c211d8124f85775f0453176fc61b312d40cb4e80
MD5 a902539a2a7fd991762e9f0508fb50c4
BLAKE2b-256 6366445e1965801a8372d1511fcad6f240e910574c9e810ed8c5866a03f92ae7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page