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)
Release files for musiio-validate-tsv 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| musiio_validate_tsv-1.0.2.tar.gz | 5.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| musiio_validate_tsv-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.6 kB
Release files / musiio_validate_tsv-1.0.2.tar.gz
| Download URL | musiio_validate_tsv-1.0.2.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
866144ee279ec9357441a80b5036ca5aea58903113c6a927f391601852fb660e
|
|
BLAKE2b-256 checksum How to use checksums |
71ca6fe9bafb483acea2b7f4f90c8cb0c758759dadf17865046a022488ca2d1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / musiio_validate_tsv-1.0.2-py3-none-any.whl
| Download URL | musiio_validate_tsv-1.0.2-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
942099e383acfbdaef4bf115c211d8124f85775f0453176fc61b312d40cb4e80
|
|
BLAKE2b-256 checksum How to use checksums |
6366445e1965801a8372d1511fcad6f240e910574c9e810ed8c5866a03f92ae7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|