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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for musiio_validate_tsv-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 866144ee279ec9357441a80b5036ca5aea58903113c6a927f391601852fb660e |
|
MD5 | 211df7134ecead316fb24d7d74e5a316 |
|
BLAKE2b-256 | 71ca6fe9bafb483acea2b7f4f90c8cb0c758759dadf17865046a022488ca2d1c |
Close
Hashes for musiio_validate_tsv-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 942099e383acfbdaef4bf115c211d8124f85775f0453176fc61b312d40cb4e80 |
|
MD5 | a902539a2a7fd991762e9f0508fb50c4 |
|
BLAKE2b-256 | 6366445e1965801a8372d1511fcad6f240e910574c9e810ed8c5866a03f92ae7 |