kraken convert
Overview
Converts records using a mapping record
github
https://github.com/tactik8/krakenconvert2
pypi
methods:
- convert: converts records
How to use:
Basics
input_records = [
{
"record_id": "1234",
"firstName": "firstName1",
"lastName": "lastName1",
"email": "test1@test.com"
}
]
mapping_record = {
"@type": "'test'",
"@id": "'/system/table/' + str(r.record_id)",
"givenName": "r.firstName",
"familyName": "r.lastName",
"email": "r.email"
}
results = convert(input_records, map)
print(results)
Structure of record
mapping_record = {
"@type": "dataset",
"name": "NAME OF THE DATASER",
"distribution": {
"@type": "DataDownload",
"contentUrl": "URL WHERE TO DOWNLOAD DATASET",
"encodingFormat": "text/tab-separated-values"
},
"variableMeasured": EXAMPLE OF RECORD (NOT USED, SIMPLY FOR REFERENCE),
"potentialAction": [
LIST OF ACTIONS
EACH REPLACEACTION REPLACE A GIVEN VALUE
- * MEANS EVERY PROPERTYID
EACH CREATEACTION CREATES A BRAND NEW RECORD
- R.NAME REFERS TO THE NAME PROPERTY OF THE RECORD
{
"@type": "replaceAction",
"replacee": {
"@type": "propertyValue",
"propertyID": "*",
"value": ".."
},
"replacer": {
"@type": "propertyValue",
"propertyID": "*",
"value": "NoneValue"
}
},
{
"@type": "replaceAction",
"replacee": {
"@type": "propertyValue",
"propertyID": "derived_NAICS",
"value": "44"
},
"replacer": {
"@type": "propertyValue",
"propertyID": "derived_NAICS",
"value": "22"
}
},
{
"@type": "createAction",
"instrument": {
"@type": "'organization'",
"name": "r.business_name",
"legalName": "r.business_name",
"naics": [
"r.derived_NAICS",
"r.source_NAICS_primary",
"r.source_NAICS_secondary"
],
"numberOfEmployees": "r.get('total_no_employees', None)",
"brand": "r.alt_business_name",
"description": "r.get('business_description', None)",
"taxID": "r.get('business_id_no', None)",
"location": {
"@type": "'place'",
"latitude": "r.latitude",
"longitude": "r.longitude",
"address": {
"@type": "'PostalAddress'",
"streetAddress": "(r.unit + ', ' + r.street_no + ' ' + r.street_name) if r.unit else (r.street_no + ' ' + r.street_name)",
"addressLocality": "r.city",
"addressRegion": "r.prov_terr",
"postalCode": "r.postal_code",
"addressCountry": "'CA'"
}
}
}
}
],
}
Example of record
mapping_record = {
"@type": "dataset",
"name": "company directory records from GoC opendata",
"distribution": {
"@type": "DataDownload",
"contentUrl": "https://www150.statcan.gc.ca/n1/pub/21-26-0003/212600032023001-eng.htm",
"encodingFormat": "text/tab-separated-values"
},
"variableMeasured": {
"idx": "87cfdddd858f54356f04",
"business_name": "Innomar Pharmacy Inc.",
"alt_business_name": "..",
"business_sector": "Community Pharmacy",
"business_subsector": "..",
"business_description": "..",
"business_id_no": "..",
"licence_number": "..",
"licence_type": "..",
"derived_NAICS": "44",
"source_NAICS_primary": "..",
"source_NAICS_secondary": "..",
"NAICS_descr": "..",
"NAICS_descr2": "..",
"latitude": "46.10593",
"longitude": "-64.80623",
"full_address": "100 Arden Street, Suite 309, Moncton Nb",
"postal_code": "..",
"unit": "..",
"street_no": "100",
"street_name": "Arden Street",
"street_direction": "..",
"street_type": "..",
"city": "Moncton",
"prov_terr": "NB",
"total_no_employees": "..",
"status": "..",
"provider": "City of Moncton",
"geo_source": "Source",
"CSDUID": "1307022",
"CSDNAME": "Moncton",
"PRUID": "13"
},
"potentialAction": [
{
"@type": "replaceAction",
"replacee": {
"@type": "propertyValue",
"propertyID": "*",
"value": ".."
},
"replacer": {
"@type": "propertyValue",
"propertyID": "*",
"value": "NoneValue"
}
},
{
"@type": "replaceAction",
"replacee": {
"@type": "propertyValue",
"propertyID": "derived_NAICS",
"value": "44"
},
"replacer": {
"@type": "propertyValue",
"propertyID": "derived_NAICS",
"value": "22"
}
},
{
"@type": "createAction",
"instrument": {
"@type": "'organization'",
"name": "r.business_name",
"legalName": "r.business_name",
"naics": [
"r.derived_NAICS",
"r.source_NAICS_primary",
"r.source_NAICS_secondary"
],
"numberOfEmployees": "r.get('total_no_employees', None)",
"brand": "r.alt_business_name",
"description": "r.get('business_description', None)",
"taxID": "r.get('business_id_no', None)",
"location": {
"@type": "'place'",
"latitude": "r.latitude",
"longitude": "r.longitude",
"address": {
"@type": "'PostalAddress'",
"streetAddress": "(r.unit + ', ' + r.street_no + ' ' + r.street_name) if r.unit else (r.street_no + ' ' + r.street_name)",
"addressLocality": "r.city",
"addressRegion": "r.prov_terr",
"postalCode": "r.postal_code",
"addressCountry": "'CA'"
}
}
}
}
],
"url": "https://www150.statcan.gc.ca/n1/pub/21-26-0003/212600032023001-eng.htm"
}
Metadata
Release files for kraken-convert 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kraken-convert-0.0.7.tar.gz | 7.9 kB | Without provenance | Details for kraken-convert-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kraken_convert-0.0.7-py3-none-any.whl | Python 3 | none | any | Details for kraken_convert-0.0.7-py3-none-any.whl |
Total release size: 15.8 kB
Release files / kraken-convert-0.0.7.tar.gz
| Download URL | kraken-convert-0.0.7.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
701e62e351903d80be3faefc70705327c547ca6a77dae56d252499384d6c7d7d
|
|
BLAKE2b-256 checksum How to use checksums |
ddc9f644647fb5f84337e485e4302f4471e046a951cfc6fc976339795fb4891f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / kraken_convert-0.0.7-py3-none-any.whl
| Download URL | kraken_convert-0.0.7-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19280fd3049d4eebca4300684b89e70e7889aa5a35b2e34504433f5719403086
|
|
BLAKE2b-256 checksum How to use checksums |
7a6e683fa1d1238e5f1bc4a8ac1ee8a04cd5f201011b6998fb1d91fce7e8fade
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Security for kraken-convert 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.