{ "info": { "author": "Neil Freeman", "author_email": "contact@fakeisthenewreal.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Natural Language :: English", "Operating System :: OS Independent", "Operating System :: Unix", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "AddFIPS\n=======\n\nAddFIPS is a tool for adding state or county FIPS codes to files that\ncontain just the names of those geographies.\n\nFIPS codes are the official ID numbers of places in the US. They're\ninvaluable for matching data from different sources.\n\nSay you have a CSV file like this:\n\n::\n\n state,county,statistic\n IL,Cook,123\n California,Los Angeles County,321\n New York,Kings,137\n LA,Orleans,99\n Alaska,Kusilvak,12\n\nAddFIPS lets you do this:\n\n::\n\n > addfips --county-field=county input.csv\n countyfp,state,county,statistic\n 17031,IL,Cook,123\n 06037,California,Los Angeles County,321\n 36047,New York,Kings,137\n 22071,LA,Orleans,99\n 02270,Alaska,Kusilvak,12\n\nInstalling\n----------\n\nAddFIPS is a Python package, compatible with Python 2.7, Python 3, and\npypy. It has no dependencies outside of Python's standard libraries.\n\nIf you've used Python packages before:\n\n::\n\n pip install addfips\n # or\n pip install --user addfips\n\nIf you haven't used Python packages before, `get\npip `__, then come\nback.\n\nYou can also clone the repo and install with\n``python setup.py install``.\n\nFeatures\n--------\n\n- Use full names or postal abbrevations for states\n- Works with all states, territories, and the District of Columbia\n- Slightly fuzzy matching allows for missing diacretic marks and\n different name formats (\"Nye County\" or \"Nye', \"Saint Louis\" or \"St.\n Louis\", \"Prince George's\" or \"Prince Georges\")\n- Includes up-to-date 2015 geographies (shout out to Kusilvak Census\n Area, AK, and Oglala Lakota Co., SD)\n\nNote that some states have counties and county-equivalent independent\ncities with the same names (e.g. Baltimore city & County, MD, Richmond\ncity & County, VA). AddFIPS's behavior may pick the wrong geography if\njust the name (\"Baltimore\") is passed.\n\nCommand line tool\n-----------------\n\n::\n\n usage: addfips [-h] [-V] [-d CHAR] (-s FIELD | -n NAME) [-c FIELD]\n [-v VINTAGE] [--no-header]\n [input]\n\n AddFIPS codes to a CSV with state and/or county names\n\n positional arguments:\n input Input file. default: stdin\n\n optional arguments:\n -h, --help show this help message and exit\n -V, --version show program's version number and exit\n -d CHAR, --delimiter CHAR\n field delimiter. default: ,\n -s FIELD, --state-field FIELD\n Read state name or FIPS code from this field\n -n NAME, --state-name NAME\n Use this state for all rows\n -c FIELD, --county-field FIELD\n Read county name from this field. If blank, only state\n FIPS code will be added\n -v VINTAGE, --vintage VINTAGE\n 2000, 2010, or 2015. default: 2015\n --no-header Input has no header now, interpret fields as integers\n -u, --err-unmatched Print rows that addfips cannot match to stderr\n\nOptions and flags: \\* ``input``: (positional argument) The name of the\nfile. If blank, ``addfips`` reads from stdin. \\* ``--delimiter``: Field\ndelimiter, defaults to ','. \\* ``--state-field``: Name of the field\ncontaining state name \\* ``--state-name``: Name, postal abbreviation or\nstate FIPS code to use for all rows. \\* ``--county-field``: Name of the\nfield containing county name. If this is blank, the output will contain\nthe two-character state FIPS code. \\* ``--vintage``: Use earlier county\nnames and FIPS codes. For instance, Clifton Forge city, VA, is not\nincluded in 2010 or later vintages. \\* ``--no-header``: Indicates that\nthe input file has no header. ``--state-field`` and ``--county-field``\nare parsed as field indices. \\* ``--err-unmatched``: Rows that\n``addfips`` cannot match will be printed to stderr, rather than stdout\n\nThe output is a CSV with a new column, \"fips\", appended to the front.\nWhen ``addfips`` cannot make a match, the fips column will have an empty\nvalue.\n\nExamples\n~~~~~~~~\n\nAdd state FIPS codes:\n\n::\n\n addfips data.csv --state-field fieldName > data_with_fips.csv\n\nAdd state and county FIPS codes:\n\n::\n\n addfips data.csv --state-field fieldName --county-field countyName > data_with_fips.csv\n\nFor files with no header row, use a number to refer to the columns with\nstate and/or county names:\n\n::\n\n addfips --no-header-row --state-field 1 --county-field 2 data_no_header.csv > data_no_header_fips.csv\n\nColumn numbers are one-indexed.\n\nAddFIPS for counties from a specific state. These are equivalent:\n\n::\n\n addfips ny_data.csv -c county --state-name NY > ny_data_fips.csv\n addfips ny_data.csv -c county --state-name 'New York' > ny_data_fips.csv\n addfips ny_data.csv -c county --state-name 36 > ny_data_fips.csv\n\nUse an alternate delimiter:\n\n::\n\n addfips -d'|' -s state pipe_delimited.dsv > result.csv\n addfips -d';' -s state semicolon_delimited.dsv > result.csv\n\nPrint unmatched rows to another file:\n\n::\n\n addfips --err-unmatched -s state state_data.csv > state_data_fips.csv 2> state_unmatched.csv\n addfips -u -s STATE -c COUNTY county_data.csv > county_data_fips.csv 2> county_unmatched.csv\n\nPipe from other programs:\n\n::\n\n curl http://example.com/data.csv | addfips -s stateFieldName -c countyField > data_with_fips.csv\n csvkit -c state,county,important huge_file.csv | addfips -s state -c county > small_file.csv\n\nPipe to other programs. In files with extensive text, filtering with the\nFIPS code is safer than using county names, which may be common words\n(e.g. cook):\n\n::\n\n addfips culinary_data.csv -s stateFieldName -c countyField | grep -e \"^17031\" > culinary_data_cook_county.csv\n addfips -s StateName -c CountyName data.csv | csvsort -c fips > sorted_by_fips.csv\n\nAPI\n---\n\nAddFIPS is available for use in your Python scripts:\n\n.. code:: python\n\n >>> import addfips\n >>> af = addfips.AddFIPS()\n >>> af.get_state_fips('Puerto Rico')\n '72'\n >>> af.get_county_fips('Nye', state_name='Nevada')\n '32023'\n >>> row = {'county': 'Cook County', 'state': 'IL'}\n >>> af.add_county_fips(row, county_field=\"county\", state_field=\"state\")\n {'county': 'Cook County', 'state': 'IL', 'fips': '17031'}\n\nThe results of ``AddFIPS.get_state_fips`` and\n``AddFIPS.get_county_fips`` are strings, since FIPS codes may have\nleading zeros.\n\nClasses\n~~~~~~~\n\nAddFIPS(vintage=None)\n^^^^^^^^^^^^^^^^^^^^^\n\nThe AddFIPS class takes one keyword argument, ``vintage``, which may be\neither ``2000``, ``2010`` or ``2015``. Any other value will use the most\nrecent vintage. Other vintages may be added in the future.\n\n**get\\_state\\_fips(self, state)** Returns two-digit FIPS code based on a\nstate name or postal code.\n\n**get\\_county\\_fips(self, county, state)** Returns five-digit FIPS code\nbased on county name and state name/abbreviation/FIPS.\n\n**add\\_state\\_fips(self, row, state\\_field='state')** Returns the input\nrow with a two-figit state FIPS code added. Input row may be either a\n``dict`` or a ``list``. If a ``dict``, the 'fips' key is added. If a\n``list``, the FIPS code is added at the start of the list.\n\n**add\\_county\\_fips(self, row, county\\_field='county',\nstate\\_field='state', state=None)** Returns the input row with a\nfive-figit county FIPS code added. Input row may be either a ``dict`` or\na ``list``. If a ``dict``, the 'fips' key is added. If a ``list``, the\nFIPS code is added at the start of the list.\n\nLicense\n~~~~~~~\n\nDistributed under the GNU General Public License, version 3. See LICENSE\nfor more information.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/fitnr/addfips", "keywords": "csv census usa data", "license": "GPL-3.0", "maintainer": null, "maintainer_email": null, "name": "addfips", "package_url": "https://pypi.org/project/addfips/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/addfips/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/fitnr/addfips" }, "release_url": "https://pypi.org/project/addfips/0.2.2/", "requires_dist": null, "requires_python": null, "summary": "Add county FIPS to tabular data", "version": "0.2.2" }, "last_serial": 2500617, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "518489886135957a8b4d38cd2c8cf5ee", "sha256": "62144d08d3b70e559272f86729c0872c5a339edbb74ecfe5d157244037b13bbf" }, "downloads": -1, "filename": "addfips-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "518489886135957a8b4d38cd2c8cf5ee", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 53061, "upload_time": "2016-01-08T01:27:54", "url": "https://files.pythonhosted.org/packages/c2/fd/74d8784f134f1001776d57026852353104f0b3e819e57db76b74756990ad/addfips-0.1.0-py2.py3-none-any.whl" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "52a767368dea8502758d66bf3160fcc4", "sha256": "7a79dfd2d9027294f38ca455802d4507360418ac33098a44e4336fe398be9eb7" }, "downloads": -1, "filename": "addfips-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "52a767368dea8502758d66bf3160fcc4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 55315, "upload_time": "2016-01-08T20:18:31", "url": "https://files.pythonhosted.org/packages/93/d1/808d59d4274642a30af2b8d0bfa5f84aad90aca8c23868c2b4a0737c668f/addfips-0.1.1-py2.py3-none-any.whl" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "1bc499fc467af5724303f7e1d384b491", "sha256": "e2c3a044cb6df7ccfa526fa4e94fe208487ea72cdb80cd000de6831735a182f6" }, "downloads": -1, "filename": "addfips-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1bc499fc467af5724303f7e1d384b491", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 78731, "upload_time": "2016-01-09T18:35:14", "url": "https://files.pythonhosted.org/packages/13/eb/bc96b86b68c1ab31aa4abe93f6b24e8c3c1a3f61f6179d2f11cbd4e41eb2/addfips-0.2.0-py2.py3-none-any.whl" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "c776fecc4fff2ebd329579672093b72d", "sha256": "9197dbc3a8e37a243052a4b2bf8bc9ee399c8f392397838ee3b2fe3786c94357" }, "downloads": -1, "filename": "addfips-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c776fecc4fff2ebd329579672093b72d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 78838, "upload_time": "2016-01-11T01:46:45", "url": "https://files.pythonhosted.org/packages/e3/65/f638a1685aa98a2e8949e6be7085153b7076b8bfd09341e7f1df52d82efb/addfips-0.2.1-py2.py3-none-any.whl" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "edd352cb347bb91becc126e65b6bc197", "sha256": "0de2e764938f9297f36597b360600ba3cd71ef11634eee7e726bb3e028412636" }, "downloads": -1, "filename": "addfips-0.2.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "edd352cb347bb91becc126e65b6bc197", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 78929, "upload_time": "2016-12-05T16:06:46", "url": "https://files.pythonhosted.org/packages/45/72/4f76cc094b3c8c302d5eddc6d961f29ca610a07ba321e919badb293422f6/addfips-0.2.2-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "edd352cb347bb91becc126e65b6bc197", "sha256": "0de2e764938f9297f36597b360600ba3cd71ef11634eee7e726bb3e028412636" }, "downloads": -1, "filename": "addfips-0.2.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "edd352cb347bb91becc126e65b6bc197", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 78929, "upload_time": "2016-12-05T16:06:46", "url": "https://files.pythonhosted.org/packages/45/72/4f76cc094b3c8c302d5eddc6d961f29ca610a07ba321e919badb293422f6/addfips-0.2.2-py2.py3-none-any.whl" } ] }