kraken-convert


Namekraken-convert JSON
Version 0.0.7 PyPI version JSON
download
home_pagehttps://github.com/tactik8/krakenconvert2
SummaryKraken convert
upload_time2024-01-24 15:14:38
maintainer
docs_urlNone
authorTactik8
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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"
}



```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tactik8/krakenconvert2",
    "name": "kraken-convert",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Tactik8",
    "author_email": "info@tactik8.com",
    "download_url": "https://files.pythonhosted.org/packages/dd/c9/f644647fb5f84337e485e4302f4471e046a951cfc6fc976339795fb4891f/kraken-convert-0.0.7.tar.gz",
    "platform": null,
    "description": "# kraken convert\n\n## Overview\nConverts records using a mapping record\n\n\n## github\nhttps://github.com/tactik8/krakenconvert2\n\n## pypi\n\n\n## methods:\n- convert: converts records\n\n\n## How to use:\n\n### Basics\n```\ninput_records = [\n        {\n        \"record_id\": \"1234\",\n        \"firstName\": \"firstName1\",\n        \"lastName\": \"lastName1\",\n        \"email\": \"test1@test.com\"\n        }\n    ]\n\n    mapping_record = {\n        \"@type\": \"'test'\",\n        \"@id\": \"'/system/table/' + str(r.record_id)\",\n        \"givenName\": \"r.firstName\",\n        \"familyName\": \"r.lastName\",\n        \"email\": \"r.email\"\n    }\n\n    results = convert(input_records, map)\n    print(results)\n\n```\n\n\n## Structure of record\n\n```\n\nmapping_record = {\n    \"@type\": \"dataset\",\n    \"name\": \"NAME OF THE DATASER\",\n    \"distribution\": {\n        \"@type\": \"DataDownload\",\n        \"contentUrl\": \"URL WHERE TO DOWNLOAD DATASET\",\n        \"encodingFormat\": \"text/tab-separated-values\"\n      },\n    \"variableMeasured\": EXAMPLE OF RECORD (NOT USED, SIMPLY FOR REFERENCE),\n    \"potentialAction\": [\n\n        LIST OF ACTIONS\n        EACH REPLACEACTION REPLACE A GIVEN VALUE\n        - * MEANS EVERY PROPERTYID\n        \n        EACH CREATEACTION CREATES A BRAND NEW RECORD\n        - R.NAME REFERS TO THE NAME PROPERTY OF THE RECORD\n        \n        {\n            \"@type\": \"replaceAction\",\n            \"replacee\": {\n                \"@type\": \"propertyValue\",\n                \"propertyID\": \"*\",\n                \"value\": \"..\"\n            },\n            \"replacer\": {\n                \"@type\": \"propertyValue\",\n                \"propertyID\": \"*\",\n                \"value\": \"NoneValue\"\n            }\n        },\n        {\n            \"@type\": \"replaceAction\",\n            \"replacee\": {\n                \"@type\": \"propertyValue\",\n                \"propertyID\": \"derived_NAICS\",\n                \"value\": \"44\"\n            },\n            \"replacer\": {\n                \"@type\": \"propertyValue\",\n                \"propertyID\": \"derived_NAICS\",\n                \"value\": \"22\"\n            }\n        },\n        {\n            \"@type\": \"createAction\",\n            \"instrument\": {\n                \"@type\": \"'organization'\",\n                \"name\": \"r.business_name\",\n                \"legalName\": \"r.business_name\",\n                \"naics\": [\n                    \"r.derived_NAICS\", \n                    \"r.source_NAICS_primary\",\n                    \"r.source_NAICS_secondary\"\n                ],\n                \"numberOfEmployees\": \"r.get('total_no_employees', None)\",\n                \"brand\": \"r.alt_business_name\",\n                \"description\":  \"r.get('business_description', None)\",\n                \"taxID\": \"r.get('business_id_no', None)\",\n                \"location\": {\n                    \"@type\": \"'place'\",\n                    \"latitude\": \"r.latitude\",\n                    \"longitude\": \"r.longitude\",\n                    \"address\": {\n                        \"@type\": \"'PostalAddress'\",\n                        \"streetAddress\": \"(r.unit + ', ' + r.street_no + ' ' +  r.street_name) if r.unit else (r.street_no + ' ' +  r.street_name)\",\n                        \"addressLocality\": \"r.city\",\n                        \"addressRegion\":  \"r.prov_terr\",\n                        \"postalCode\": \"r.postal_code\",\n                        \"addressCountry\": \"'CA'\"\n                    }\n                }\n            }\n        }\n    ],\n}\n\n\n\n```\n\n\n## Example of record\n```\n\nmapping_record = {\n    \"@type\": \"dataset\",\n    \"name\": \"company directory records from GoC opendata\",\n    \"distribution\": {\n        \"@type\": \"DataDownload\",\n        \"contentUrl\": \"https://www150.statcan.gc.ca/n1/pub/21-26-0003/212600032023001-eng.htm\",\n        \"encodingFormat\": \"text/tab-separated-values\"\n      },\n    \"variableMeasured\": {\n        \"idx\": \"87cfdddd858f54356f04\", \n        \"business_name\": \"Innomar Pharmacy Inc.\", \n        \"alt_business_name\": \"..\", \n        \"business_sector\": \"Community Pharmacy\", \n        \"business_subsector\": \"..\", \n        \"business_description\": \"..\", \n        \"business_id_no\": \"..\", \n        \"licence_number\": \"..\", \n        \"licence_type\": \"..\", \n        \"derived_NAICS\": \"44\", \n        \"source_NAICS_primary\": \"..\", \n        \"source_NAICS_secondary\": \"..\", \n        \"NAICS_descr\": \"..\", \n        \"NAICS_descr2\": \"..\", \n        \"latitude\": \"46.10593\", \n        \"longitude\": \"-64.80623\", \n        \"full_address\": \"100 Arden Street, Suite 309, Moncton Nb\", \n        \"postal_code\": \"..\", \n        \"unit\": \"..\", \n        \"street_no\": \"100\", \n        \"street_name\": \"Arden Street\", \n        \"street_direction\": \"..\", \n        \"street_type\": \"..\", \n        \"city\": \"Moncton\", \n        \"prov_terr\": \"NB\", \n        \"total_no_employees\": \"..\", \n        \"status\": \"..\", \n        \"provider\": \"City of Moncton\", \n        \"geo_source\": \"Source\", \n        \"CSDUID\": \"1307022\", \n        \"CSDNAME\": \"Moncton\", \n        \"PRUID\": \"13\"\n    },\n    \"potentialAction\": [\n        {\n            \"@type\": \"replaceAction\",\n            \"replacee\": {\n                \"@type\": \"propertyValue\",\n                \"propertyID\": \"*\",\n                \"value\": \"..\"\n            },\n            \"replacer\": {\n                \"@type\": \"propertyValue\",\n                \"propertyID\": \"*\",\n                \"value\": \"NoneValue\"\n            }\n        },\n        {\n            \"@type\": \"replaceAction\",\n            \"replacee\": {\n                \"@type\": \"propertyValue\",\n                \"propertyID\": \"derived_NAICS\",\n                \"value\": \"44\"\n            },\n            \"replacer\": {\n                \"@type\": \"propertyValue\",\n                \"propertyID\": \"derived_NAICS\",\n                \"value\": \"22\"\n            }\n        },\n        {\n            \"@type\": \"createAction\",\n            \"instrument\": {\n                \"@type\": \"'organization'\",\n                \"name\": \"r.business_name\",\n                \"legalName\": \"r.business_name\",\n                \"naics\": [\n                    \"r.derived_NAICS\", \n                    \"r.source_NAICS_primary\",\n                    \"r.source_NAICS_secondary\"\n                ],\n                \"numberOfEmployees\": \"r.get('total_no_employees', None)\",\n                \"brand\": \"r.alt_business_name\",\n                \"description\":  \"r.get('business_description', None)\",\n                \"taxID\": \"r.get('business_id_no', None)\",\n                \"location\": {\n                    \"@type\": \"'place'\",\n                    \"latitude\": \"r.latitude\",\n                    \"longitude\": \"r.longitude\",\n                    \"address\": {\n                        \"@type\": \"'PostalAddress'\",\n                        \"streetAddress\": \"(r.unit + ', ' + r.street_no + ' ' +  r.street_name) if r.unit else (r.street_no + ' ' +  r.street_name)\",\n                        \"addressLocality\": \"r.city\",\n                        \"addressRegion\":  \"r.prov_terr\",\n                        \"postalCode\": \"r.postal_code\",\n                        \"addressCountry\": \"'CA'\"\n                    }\n                }\n            }\n        }\n    ],\n    \"url\": \"https://www150.statcan.gc.ca/n1/pub/21-26-0003/212600032023001-eng.htm\"\n}\n\n\n\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Kraken convert",
    "version": "0.0.7",
    "project_urls": {
        "Homepage": "https://github.com/tactik8/krakenconvert2"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7a6e683fa1d1238e5f1bc4a8ac1ee8a04cd5f201011b6998fb1d91fce7e8fade",
                "md5": "914f1c2f58d5d321ece498992000e71f",
                "sha256": "19280fd3049d4eebca4300684b89e70e7889aa5a35b2e34504433f5719403086"
            },
            "downloads": -1,
            "filename": "kraken_convert-0.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "914f1c2f58d5d321ece498992000e71f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7814,
            "upload_time": "2024-01-24T15:14:37",
            "upload_time_iso_8601": "2024-01-24T15:14:37.358176Z",
            "url": "https://files.pythonhosted.org/packages/7a/6e/683fa1d1238e5f1bc4a8ac1ee8a04cd5f201011b6998fb1d91fce7e8fade/kraken_convert-0.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ddc9f644647fb5f84337e485e4302f4471e046a951cfc6fc976339795fb4891f",
                "md5": "1d366701df12ac6db396a2dec6158351",
                "sha256": "701e62e351903d80be3faefc70705327c547ca6a77dae56d252499384d6c7d7d"
            },
            "downloads": -1,
            "filename": "kraken-convert-0.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "1d366701df12ac6db396a2dec6158351",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7939,
            "upload_time": "2024-01-24T15:14:38",
            "upload_time_iso_8601": "2024-01-24T15:14:38.804633Z",
            "url": "https://files.pythonhosted.org/packages/dd/c9/f644647fb5f84337e485e4302f4471e046a951cfc6fc976339795fb4891f/kraken-convert-0.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-24 15:14:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tactik8",
    "github_project": "krakenconvert2",
    "github_not_found": true,
    "lcname": "kraken-convert"
}
        
Elapsed time: 0.32554s