{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "# LocusHandler\n\nThis package was created to automate Locus coded data processing steps. It provides functions to parse and validate\nLocus codes. It also allows to process entire data files that use the Locus classification system or other common economic\nclassification systems such as NAICS or SOC.\n\n[![PyPI version](https://badge.fury.io/py/locushandler.svg)](https://badge.fury.io/py/locushandler)\n[![Build Status](https://semaphoreci.com/api/v1/projects/f153f328-ef80-4f95-b85a-408e1a8d13ba/2377361/badge.svg)](https://semaphoreci.com/locusanalytics/locushandler)\n\n## Getting Started\n\n### Installation\n\nThe package can be downloaded and installed using pip.\n\n```\npip install locushandler\n```\n\nYou will then be able to import the package in your Python scripts.\n\n```\nimport locushandler as lh\n```\n\nYou can also import specific parts of the package.\n\n```\nimport locushandler.string_parser as sp\nimport locushandler.file_handler as fh\n```\n\n### Prerequisites\n\nThe LocusHandler is coded in Python 3.\nUsing pip install, all Python libraries required to use the LocusHandler should be automatically installed on your machine.\n\n## How to use the LocusHandler\n\n#### Granularity\n\nThe granularity parameters takes in a string with the format \\x\\ with \\\nin \\[1,4,12,36\\] and \\ in \\[1,6,6x4,6x4x3\\]\n\n##### Activity\n\n- '1' : no activity\n- '4' : 4 phases activty cycle\n- '12' : 12 phases activity cycle\n- '36' : 36 phases activity cycle\n\n##### Resource\n\n- '1' : no resource\n- '6' : resource categories\n- '6x4' : resource categories staged\n- '6x4x3' : resource categories sub-staged\n\n##### Examples\n\n- Work Locus : - 4x6 : 1 B, 3 F - 12x6x4 : (B4) 1.2 B4, 2.2 C3 - 36x6x4x3 : 3.3.1 E3ii, (B4ii) 3.1.2 Div\n- Resource Locus : - 1x6 : B, F - 12x6x4 : B4 2.2 B4, A4 1.3 C3 - 36x6x4x3 : B4ii 1.2.2 E3ii, B4ii 2.2.2 Div\n\n##### Input syntax\n\n- The LocusHandler assumes that all work loci contain parentheses around the Distinguishing Resources and the Information Outputs.\n Please make sure that the input data follows that syntax.\n\n#### Parsing a Locus code\n\nThe string_parser module allows you to parse any work or resource Loci, in a string format, such as\n\n```\n'(B4ii) 1.2.2 B4i'\n'B4ii 2.2.2 F'\n```\n\nand get a list, a dictionary or a string of that code at the required granularity.\n\n##### Parsing to a dictionary\n\n```\nsp.string_parser('(B4ii) 1.2.2 B4Div', 'dict', '36x6x4x3', show_dr=True, show_io=True))\n```\n\nwill return the following dictionary\n\n```\n{'dr': {'r1': 'B', 'r2': '4', 'r3': 'ii'},\n 'act': {'a1': '1', 'a2': '2', 'a3': '2'},\n 'obj': {'r1': 'B', 'r2': '4', 'r3': 'V'},\n 'io': {'r1': '', 'r2': '', 'r3': ''}\n }\n```\n\nmake use of the `merge_fields` parameter to return (field, field value) pairs:\n\n```\nsp.string_parser('(B4ii) 1.2.2 B4Div', 'dict', '36x6x4x3', show_dr=True, show_io=True))\n```\n\nwill return the following dictionary\n\n```\n{'dr': 'B4ii',\n 'act': '1.2.2',\n 'obj': 'B4V',\n 'io': ''\n}\n```\n\n##### Parsing to a list\n\n```\nsp.string_parser('(B4ii) 1.2.2 B4Div', 'list', '4x6', show_dr=True, show_io=True))\n```\n\nwill return the following list\n\n```\n['B','2','B','']\n```\n\n##### Parsing to a string\n\n```\nsp.string_parser('(B4ii) 1.2.2 B4Div', 'string', '12x6x4', show_dr=False, show_io=False))\n```\n\nwill return the following string\n\n```\n'1.2 B4'\n```\n\n#### Parsing a Locus code column in a file\n\nThe file_handler module allows you to parse an entire column of a .csv file. If the input file contains Locus code as strings\nthe function parse_file can parse it and return a Dataframe or a name of a new saved .csv file with columns containing\neach element the Locus code at the required granularity.\nAn example of input data would be the following table.\n\n| Enterprise_Locus | Employment level | ... | Area | Year |\n| :----------------: | :--------------: | :-: | :--: | :--: |\n| '(B4ii) 1.2.2 B4i' | 1366 | ... | NY | 2010 |\n| (A4iii) 3.3.2 B3ii | 235 | ... | VA | 2008 |\n| ... | ... | ... | ... | ... |\n| '(B4ii) 1.3.2 F' | 78 | ... | KS | 2010 |\n\n##### Parsing to a Pandas dataframe\n\n```\nfh.parse_file('file.csv', 'Enterprise_Locus', 'df', '12x6x4x3', show_dr=False, show_io=False)\n```\n\nwould return a Pandas dataframe with the following information\n\n| a1 | a2 | r1 | r2 | r3 | Employment level | ... | Area | Year |\n| :-: | --- | --- | --- | --- | :--------------: | :-: | :--: | :--: |\n| 1 | 2 | B | 4 | i | 1366 | ... | NY | 2010 |\n| 3 | 3 | B | 3 | ii | 235 | ... | VA | 2008 |\n| ... | ... | ... | ... | ... | ... | ... | ... | ... |\n| 1 | 3 | F | | | 78 | ... | KS | 2010 |\n\n##### Parsing to a new .csv file\n\n```\nfh.parse_file('file.csv', 'Enterprise_Locus', 'path', '12x6x4x3', show_dr=False, show_io=False)\n```\n\nwould return the path of the new .csv file that contain the same information as above. In this case, the path would be\n'file_parsed_12x6x4x3_Enterprise_Locus.csv'\n\n#### Mapping to Locus codes\n\nIf the input data uses a common classification system, the LocusHandler provide a function to map the input data\nto Locus code at the desired granularity.\nAn example of input data would be the following table.\n\n| Naics | Employment level | ... | Area | Year |\n| :---: | :--------------: | :-: | :-----: | :--: |\n| 13589 | 3468735 | ... | USA | 2010 |\n| 78621 | 87685 | ... | FRANCE | 2008 |\n| ... | ... | ... | ... | ... |\n| 34697 | 34786 | ... | NIGERIA | 2010 |\n\nTo call the map_to_locus you need the path of your input file (file_naics.csv), the name of the column with the classification system you map from (Naics)\n, the name of the column of the classification sytem in the crosswalk file (NAICS5), the path to the crosswalk file (naics2locus.csv),\nthe barcode field you are interested in (enterprise_locus), the granularity (4x6) and the need for dr and io.\n\n```\nfh.map_to_locus('file_naics.csv', 'Naics', 'NAICS5', 'naics2locus.csv', 'entreprise_locus','4x6', show_dr=True, show_io=True)\n```\n\nwould return a Pandas dataframe with the following information\\*.\n\n| dr1 | a1 | r1 | io1 | Employment level | ... | Area | Year |\n| :-: | --- | --- | --- | :--------------: | :-: | :-----: | :--: |\n| B | 1 | B | | 3468735 | ... | USA | 2010 |\n| | 2 | A | C | 87685 | ... | FRANCE | 2008 |\n| ... | ... | ... | ... | ... | ... | ... | ... |\n| A | 3 | B | | 34786 | ... | NIGERIA | 2010 |\n\n\\*Naics to Locus mapping not accurate here\n\n## Documentation\n\n- Please read the [Technical Brief](https://docs.google.com/document/d/1g6RVpLE9jD7m-sXWsKmVoSy5to0a9FnqfS2JWlOnsTk/edit) for details on the project.\n- Please read the [Specs](https://docs.google.com/document/d/15FfZJx9haLjSG1PLc4e9lLvEul713Eela-s5Uq7Wp1A/edit?usp=sharing) for details on the functions available.\n\n## Authors\n\n- **[Phillip Nguyen](mailto:pnguyen@locus.co)** - _String parsing_\n- **[Olivia Dalglish](mailto:odalglish@locus.co)** - _Code validation_\n- **[Emeline Floc'h](mailto:efloch@locus.co)** - _File handling_\n\n## Contributors\n\n- **Vinharng Chew** - **Stefanie Bourland** - **Chris Haack** - **Aaron Lee** - **Atul Prasad** - _Reviewers_", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/LocusAnalytics/LocusHandler", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "locushandler", "package_url": "https://pypi.org/project/locushandler/", "platform": "", "project_url": "https://pypi.org/project/locushandler/", "project_urls": { "Homepage": "https://github.com/LocusAnalytics/LocusHandler" }, "release_url": "https://pypi.org/project/locushandler/0.2.0/", "requires_dist": null, "requires_python": "", "summary": "", "version": "0.2.0" }, "last_serial": 5419356, "releases": { "0.1.1.dev0": [ { "comment_text": "", "digests": { "md5": "e300c846c721ae5995b638f026d6d30d", "sha256": "fde81a57415530d2788c7168076369f8284102e0af777beeee1a9c56a895f508" }, "downloads": -1, "filename": "locushandler-0.1.1.dev0.tar.gz", "has_sig": false, "md5_digest": "e300c846c721ae5995b638f026d6d30d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 829, "upload_time": "2018-11-19T21:28:51", "url": "https://files.pythonhosted.org/packages/d8/a7/7732b2ad28772da6d2ae7eb3b43d175126c857b3f4aee3456c8d733554a0/locushandler-0.1.1.dev0.tar.gz" } ], "0.1.10": [ { "comment_text": "", "digests": { "md5": "65fe45e7b6425e58dcf9edefa857d2d7", "sha256": "8e4f0988d388425d53a118fa235419096c9f506a623e91ed1c9813769c8c6229" }, "downloads": -1, "filename": "locushandler-0.1.10.tar.gz", "has_sig": false, "md5_digest": "65fe45e7b6425e58dcf9edefa857d2d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15505, "upload_time": "2019-01-18T15:00:07", "url": "https://files.pythonhosted.org/packages/90/24/fc82ae7d0b16ed61b572bb53a3be5d6d1b232cf91799cb3880ff6a4d5580/locushandler-0.1.10.tar.gz" } ], "0.1.11": [ { "comment_text": "", "digests": { "md5": "037506955764a6f92c64863d843302f0", "sha256": "59e3e7caf7aa8980e45475e674f1ea47e2557fee493064ea3142de5ec990b8c7" }, "downloads": -1, "filename": "locushandler-0.1.11.tar.gz", "has_sig": false, "md5_digest": "037506955764a6f92c64863d843302f0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15724, "upload_time": "2019-02-04T23:07:12", "url": "https://files.pythonhosted.org/packages/ec/3d/7743f16434cb11190d916cfafa2e20c6a19560570e3d3a0ebf87e48e551b/locushandler-0.1.11.tar.gz" } ], "0.1.12": [ { "comment_text": "", "digests": { "md5": "c0d631b1014e95620aea697a084e1379", "sha256": "3eb5f2f96b5ad5065148c0cd069a7b7390a968a248109e48a199cdaed66d5f53" }, "downloads": -1, "filename": "locushandler-0.1.12.tar.gz", "has_sig": false, "md5_digest": "c0d631b1014e95620aea697a084e1379", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15770, "upload_time": "2019-02-06T21:31:43", "url": "https://files.pythonhosted.org/packages/c5/13/29f50dbaf8c4c80686b064d854f5387174664ff19b02dc9d612fd68065b6/locushandler-0.1.12.tar.gz" } ], "0.1.13": [ { "comment_text": "", "digests": { "md5": "ded3553c198762d529e743a4e703ea94", "sha256": "d6708df42e65dee89de937e39e92c3c6594ee24bd6788840dab8665501dcf2df" }, "downloads": -1, "filename": "locushandler-0.1.13.tar.gz", "has_sig": false, "md5_digest": "ded3553c198762d529e743a4e703ea94", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15780, "upload_time": "2019-02-07T20:01:00", "url": "https://files.pythonhosted.org/packages/d0/1e/c09dd198c947969c2097ed592998e34520de08f4ef13013bf2756e35407b/locushandler-0.1.13.tar.gz" } ], "0.1.14": [ { "comment_text": "", "digests": { "md5": "3a8ec48375e4f91f08b1d655e15bc680", "sha256": "70a16a36d04c06741a5d32cd49fb480341d56ef933f241b784990ebcacd7d4d1" }, "downloads": -1, "filename": "locushandler-0.1.14.tar.gz", "has_sig": false, "md5_digest": "3a8ec48375e4f91f08b1d655e15bc680", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16951, "upload_time": "2019-04-29T20:07:48", "url": "https://files.pythonhosted.org/packages/f1/02/0d1d55fdf1a98ee8dc54d3441abdfd83da709d788e77b5f291a48db3ef40/locushandler-0.1.14.tar.gz" } ], "0.1.2.dev0": [ { "comment_text": "", "digests": { "md5": "08df4771d7384809157a8ea839495176", "sha256": "6dd0f3429a7cfc4573c6136185fad33ce6e0f18ae113340e151e263a0d94fc0c" }, "downloads": -1, "filename": "locushandler-0.1.2.dev0.tar.gz", "has_sig": false, "md5_digest": "08df4771d7384809157a8ea839495176", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 825, "upload_time": "2018-11-19T21:46:53", "url": "https://files.pythonhosted.org/packages/33/cb/203395ba05c43e464858fadfcc23dcf007f5198fbb4086e975962c26c79b/locushandler-0.1.2.dev0.tar.gz" } ], "0.1.3.2.dev0": [ { "comment_text": "", "digests": { "md5": "3cbdda8b3d3c4a287ab3bb07cefe4f2b", "sha256": "b39bce5dbf81a333809d39e3ac8ef52b471aeb4313809b7542cff6dc757ba019" }, "downloads": -1, "filename": "locushandler-0.1.3.2.dev0.tar.gz", "has_sig": false, "md5_digest": "3cbdda8b3d3c4a287ab3bb07cefe4f2b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8369, "upload_time": "2018-11-19T21:46:54", "url": "https://files.pythonhosted.org/packages/fe/f0/0d4a1394fec17c6660a1aa1efac39e77d7cc5f6ebca58cd4c3486e5aa4c7/locushandler-0.1.3.2.dev0.tar.gz" } ], "0.1.3.dev0": [ { "comment_text": "", "digests": { "md5": "360878e6b91254cd23ef5ee687247f0d", "sha256": "b76d900fd136d760356dab629e7dffb732a7d385eb1229bcaff15a1d0f607449" }, "downloads": -1, "filename": "locushandler-0.1.3.dev0.tar.gz", "has_sig": false, "md5_digest": "360878e6b91254cd23ef5ee687247f0d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 832, "upload_time": "2018-11-19T21:46:55", "url": "https://files.pythonhosted.org/packages/5e/d6/04fd7f268a0728a349a66c0f24e980bc0402654c7a0baa72ef2fcbb11a74/locushandler-0.1.3.dev0.tar.gz" } ], "0.1.4.dev0": [ { "comment_text": "", "digests": { "md5": "8dcd0a471e1ecdb7bec0cd601d61d6df", "sha256": "ac687af640fbca0926d2fa3230dd5361c8d0a7506176d0133af25fb73d508550" }, "downloads": -1, "filename": "locushandler-0.1.4.dev0.tar.gz", "has_sig": false, "md5_digest": "8dcd0a471e1ecdb7bec0cd601d61d6df", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13560, "upload_time": "2018-11-29T22:58:33", "url": "https://files.pythonhosted.org/packages/cb/fe/a4d46f1ebba627ab5786ddb811135936d5d56c5f5b3eaa810fe576cf74a7/locushandler-0.1.4.dev0.tar.gz" } ], "0.1.5.dev0": [ { "comment_text": "", "digests": { "md5": "b067649fc70e504ada3fcd5195b3d3b2", "sha256": "6a20ed8ba1e7d25f4a145f62f2a0389b61ae2eb87cad9a61255b05fedbbe91fc" }, "downloads": -1, "filename": "locushandler-0.1.5.dev0.tar.gz", "has_sig": false, "md5_digest": "b067649fc70e504ada3fcd5195b3d3b2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13557, "upload_time": "2018-11-29T22:59:37", "url": "https://files.pythonhosted.org/packages/66/ef/0a3da04bd9c5e7b651dd538a1dad3f9a3e39409133ce96967a0a7a4e4f4f/locushandler-0.1.5.dev0.tar.gz" } ], "0.1.6.dev0": [ { "comment_text": "", "digests": { "md5": "82073fc51289d455cbdb6092877da088", "sha256": "c27e5050ab4bc1f80039b97f29ab24c1bd93b4f48d304de8bf6430d1064829d1" }, "downloads": -1, "filename": "locushandler-0.1.6.dev0.tar.gz", "has_sig": false, "md5_digest": "82073fc51289d455cbdb6092877da088", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13836, "upload_time": "2018-11-30T21:44:47", "url": "https://files.pythonhosted.org/packages/4a/1d/dabbe6951ee2351855c1bbfffd670f6d3ad2b195ff786f621255b8d4f511/locushandler-0.1.6.dev0.tar.gz" } ], "0.1.7": [ { "comment_text": "", "digests": { "md5": "6845b1a4957d7057cfd32caca479342a", "sha256": "0fd88c40cd5e58961a8e76b137d1077b984d2ecef6148e4568d5fd456b893cc0" }, "downloads": -1, "filename": "locushandler-0.1.7.tar.gz", "has_sig": false, "md5_digest": "6845b1a4957d7057cfd32caca479342a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14275, "upload_time": "2018-12-12T14:30:04", "url": "https://files.pythonhosted.org/packages/32/d6/6fe8ed16ce0d299d5ab5b16bba3374f5984a06bf33a9432b72967184913c/locushandler-0.1.7.tar.gz" } ], "0.1.8": [ { "comment_text": "", "digests": { "md5": "9ab6621ed3ca2d52bf8ff0f3bff33c60", "sha256": "67a53a0870ed0718e02f26943ee01c2bbc41ca87007bf3ec4490e647ce406159" }, "downloads": -1, "filename": "locushandler-0.1.8.tar.gz", "has_sig": false, "md5_digest": "9ab6621ed3ca2d52bf8ff0f3bff33c60", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15364, "upload_time": "2019-01-08T21:43:30", "url": "https://files.pythonhosted.org/packages/7c/71/84214fbf38efc8e61e6bc39a2cfe0dca1be1b81f3a52dbd5a8dd0f0ef874/locushandler-0.1.8.tar.gz" } ], "0.1.9": [ { "comment_text": "", "digests": { "md5": "cc6786a6046f2b895038893ebee664f9", "sha256": "5abcd936cf6ad3b4bb26af239e9cb036d805007ac4baa2b034fc75b2e9df5005" }, "downloads": -1, "filename": "locushandler-0.1.9.tar.gz", "has_sig": false, "md5_digest": "cc6786a6046f2b895038893ebee664f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15418, "upload_time": "2019-01-09T14:51:04", "url": "https://files.pythonhosted.org/packages/7e/c2/19f51a0625c0cdcda02a2594116634f54d777617ee7548d9a774feb571bd/locushandler-0.1.9.tar.gz" } ], "0.1.dev0": [ { "comment_text": "", "digests": { "md5": "e3f5288ee4561ada98ea0598af4606a7", "sha256": "787d6c9353b0681c5114fb371ef16b17434d03b1e5b50a4c1a9c45068964bcbc" }, "downloads": -1, "filename": "locushandler-0.1.dev0-py3-none-any.whl", "has_sig": false, "md5_digest": "e3f5288ee4561ada98ea0598af4606a7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 1142, "upload_time": "2018-11-19T21:08:52", "url": "https://files.pythonhosted.org/packages/8f/50/e7e0acd3b1e04636325ce08f194ab1e71c17ff41421fa96672b1085df098/locushandler-0.1.dev0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f79a176b9c7b8477e03b03816087fd07", "sha256": "4cd8370dfc8a1e0793efbd9694fdea0299c5e58ba2b71ab92d0eef0eb9cba943" }, "downloads": -1, "filename": "locushandler-0.1.dev0.tar.gz", "has_sig": false, "md5_digest": "f79a176b9c7b8477e03b03816087fd07", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 825, "upload_time": "2018-11-19T21:08:54", "url": "https://files.pythonhosted.org/packages/27/5a/061d46d60d6f554c121c1c49201766550af36550e0f0558002379007c302/locushandler-0.1.dev0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "753148e435a0f3b3493c6ed9d9c8d22d", "sha256": "e4c7119ec72e89b71f3cd43a41c426a89740781bd981ee6928a766af9fe37097" }, "downloads": -1, "filename": "locushandler-0.2.0.tar.gz", "has_sig": false, "md5_digest": "753148e435a0f3b3493c6ed9d9c8d22d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16887, "upload_time": "2019-06-19T09:08:24", "url": "https://files.pythonhosted.org/packages/f6/57/7ecdac4043032743c4723d891ae75aa3eb3c52d9d2076bac2a1aeb04e4a3/locushandler-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "753148e435a0f3b3493c6ed9d9c8d22d", "sha256": "e4c7119ec72e89b71f3cd43a41c426a89740781bd981ee6928a766af9fe37097" }, "downloads": -1, "filename": "locushandler-0.2.0.tar.gz", "has_sig": false, "md5_digest": "753148e435a0f3b3493c6ed9d9c8d22d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16887, "upload_time": "2019-06-19T09:08:24", "url": "https://files.pythonhosted.org/packages/f6/57/7ecdac4043032743c4723d891ae75aa3eb3c52d9d2076bac2a1aeb04e4a3/locushandler-0.2.0.tar.gz" } ] }