NeoBase |actions|_ |cratev|_ |crated|_
======================================
.. _actions : https://github.com/alexprengere/neobase/actions/workflows/python-package.yml
.. |actions| image:: https://github.com/alexprengere/neobase/actions/workflows/python-package.yml/badge.svg
.. _cratev : https://pypi.org/project/NeoBase/
.. |cratev| image:: https://img.shields.io/pypi/v/neobase.svg
.. _crated : https://pypi.org/project/NeoBase/
.. |crated| image:: https://static.pepy.tech/badge/neobase
Minimalist `GeoBases <https://github.com/opentraveldata/geobases/>`__
implementation:
- no dependencies
- compatible with Python 3.9+, CPython and PyPy
- one data source:
`opentraveldata <https://github.com/opentraveldata/opentraveldata>`__
- one Python module for easier distribution on clusters (like Hadoop)
- faster load time (5x)
- tested with pytest and tox
.. code:: python
>>> from neobase import NeoBase
>>> b = NeoBase()
>>> b.get('ORY', 'city_code_list')
['PAR']
>>> b.get('ORY', 'city_name_list')
['Paris']
>>> b.get('ORY', 'country_code')
'FR'
>>> b.distance('ORY', 'CDG')
34.87...
>>> b.get_location('ORY')
LatLng(lat=48.72..., lng=2.35...)
Installation
------------
Use the Python package:
.. code:: bash
pip install neobase
Docs
----
Check out `readthedocs <http://neobase.readthedocs.org/en/latest/>`__ for the API.
You can customize the source data when initializing:
.. code:: python
with open("file.csv") as f:
N = NeoBase(f)
Otherwise the loaded file will be the embedded one, unless the ``OPTD_POR_FILE`` environment variable is set. In that case, it will load from the path defined in that variable.
You can manually retrieve the latest data source yourself too, but you expose yourself to some breaking changes if they occur in the data.
.. code:: python
from io import StringIO
from urllib.request import urlopen
from neobase import NeoBase, OPTD_POR_URL
data = urlopen(OPTD_POR_URL).read().decode('utf8')
N = NeoBase(StringIO(data))
N.get("PAR")
The reference date of validity can be changed as well:
.. code:: python
N = NeoBase(date="2000-01-01")
N.get("AIY") # was decommissioned in 2015
By default, the reference date will be set to today, unless the ``OPTD_POR_DATE`` environment variable is set. In that case, it will use that value.
You can customize the behavior regarding duplicates: points sharing the same IATA code, like NCE as airport and NCE as city. By default everything is kept, but you can set it so that only the first point with an IATA code is kept:
.. code:: python
N = NeoBase(duplicates=False)
len(N) # about 10,000 "only"
Note that you can use the ``OPTD_POR_DUPLICATES`` environment variable to control this as well: set it to ``0`` to drop duplicates.
Finally, you can customize fields loaded by subclassing.
.. code:: python
class SubNeoBase(NeoBase):
KEY = 0 # iata_code
# Those loaded fields are the default ones
FIELDS = (
("name", 6, None),
("lat", 8, None),
("lng", 9, None),
("page_rank", 12, lambda s: float(s) if s else None),
("country_code", 16, None),
("country_name", 18, None),
('continent_name', 19, None),
("timezone", 31, None),
("city_code_list", 36, lambda s: s.split(",")),
('city_name_list', 37, lambda s: s.split('=')),
('location_type', 41, None),
("currency", 46, None),
)
N = SubNeoBase()
Command-line interface
----------------------
You can query the data using:
.. code:: bash
python -m neobase PAR NCE
Tests
-----
.. code:: bash
tox
Raw data
{
"_id": null,
"home_page": "https://github.com/alexprengere/neobase",
"name": "NeoBase",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Alex Preng\u00e8re",
"author_email": "alex.prengere@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/68/ec/8e8e3224c28798e87d14327e8a3b644db966e9d552c5e8e6917418ef4b22/neobase-0.34.3.tar.gz",
"platform": null,
"description": "NeoBase |actions|_ |cratev|_ |crated|_\n======================================\n\n.. _actions : https://github.com/alexprengere/neobase/actions/workflows/python-package.yml\n.. |actions| image:: https://github.com/alexprengere/neobase/actions/workflows/python-package.yml/badge.svg\n\n.. _cratev : https://pypi.org/project/NeoBase/\n.. |cratev| image:: https://img.shields.io/pypi/v/neobase.svg\n\n.. _crated : https://pypi.org/project/NeoBase/\n.. |crated| image:: https://static.pepy.tech/badge/neobase\n\nMinimalist `GeoBases <https://github.com/opentraveldata/geobases/>`__\nimplementation:\n\n- no dependencies\n- compatible with Python 3.9+, CPython and PyPy\n- one data source:\n `opentraveldata <https://github.com/opentraveldata/opentraveldata>`__\n- one Python module for easier distribution on clusters (like Hadoop)\n- faster load time (5x)\n- tested with pytest and tox\n\n.. code:: python\n\n >>> from neobase import NeoBase\n >>> b = NeoBase()\n >>> b.get('ORY', 'city_code_list')\n ['PAR']\n >>> b.get('ORY', 'city_name_list')\n ['Paris']\n >>> b.get('ORY', 'country_code')\n 'FR'\n >>> b.distance('ORY', 'CDG')\n 34.87...\n >>> b.get_location('ORY')\n LatLng(lat=48.72..., lng=2.35...)\n\nInstallation\n------------\n\nUse the Python package:\n\n.. code:: bash\n\n pip install neobase\n\nDocs\n----\n\nCheck out `readthedocs <http://neobase.readthedocs.org/en/latest/>`__ for the API.\n\nYou can customize the source data when initializing:\n\n.. code:: python\n\n with open(\"file.csv\") as f:\n N = NeoBase(f)\n\nOtherwise the loaded file will be the embedded one, unless the ``OPTD_POR_FILE`` environment variable is set. In that case, it will load from the path defined in that variable.\n\nYou can manually retrieve the latest data source yourself too, but you expose yourself to some breaking changes if they occur in the data.\n\n.. code:: python\n\n from io import StringIO\n from urllib.request import urlopen\n\n from neobase import NeoBase, OPTD_POR_URL\n\n data = urlopen(OPTD_POR_URL).read().decode('utf8')\n N = NeoBase(StringIO(data))\n N.get(\"PAR\")\n\nThe reference date of validity can be changed as well:\n\n.. code:: python\n\n N = NeoBase(date=\"2000-01-01\")\n N.get(\"AIY\") # was decommissioned in 2015\n\nBy default, the reference date will be set to today, unless the ``OPTD_POR_DATE`` environment variable is set. In that case, it will use that value.\n\nYou can customize the behavior regarding duplicates: points sharing the same IATA code, like NCE as airport and NCE as city. By default everything is kept, but you can set it so that only the first point with an IATA code is kept:\n\n.. code:: python\n\n N = NeoBase(duplicates=False)\n len(N) # about 10,000 \"only\"\n\nNote that you can use the ``OPTD_POR_DUPLICATES`` environment variable to control this as well: set it to ``0`` to drop duplicates.\n\nFinally, you can customize fields loaded by subclassing.\n\n.. code:: python\n\n class SubNeoBase(NeoBase):\n KEY = 0 # iata_code\n\n # Those loaded fields are the default ones\n FIELDS = (\n (\"name\", 6, None),\n (\"lat\", 8, None),\n (\"lng\", 9, None),\n (\"page_rank\", 12, lambda s: float(s) if s else None),\n (\"country_code\", 16, None),\n (\"country_name\", 18, None),\n ('continent_name', 19, None),\n (\"timezone\", 31, None),\n (\"city_code_list\", 36, lambda s: s.split(\",\")),\n ('city_name_list', 37, lambda s: s.split('=')),\n ('location_type', 41, None),\n (\"currency\", 46, None),\n )\n\n N = SubNeoBase()\n\nCommand-line interface\n----------------------\n\nYou can query the data using:\n\n.. code:: bash\n\n python -m neobase PAR NCE\n\nTests\n-----\n\n.. code:: bash\n\n tox\n",
"bugtrack_url": null,
"license": null,
"summary": "Python library to manipulate Open Travel Data",
"version": "0.34.3",
"project_urls": {
"Homepage": "https://github.com/alexprengere/neobase"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "35cd4bdb57f22f320397f65e555c47b5c8d9b963d6254999bc227b531a7f202a",
"md5": "8d7cc42d31a9b0d263710b22a7ea7553",
"sha256": "f8e5ff101490c9b97d0494a5eaa428ded3333803beacc2e6def3c59e58e47f8f"
},
"downloads": -1,
"filename": "NeoBase-0.34.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8d7cc42d31a9b0d263710b22a7ea7553",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 3964255,
"upload_time": "2025-01-13T08:11:03",
"upload_time_iso_8601": "2025-01-13T08:11:03.604256Z",
"url": "https://files.pythonhosted.org/packages/35/cd/4bdb57f22f320397f65e555c47b5c8d9b963d6254999bc227b531a7f202a/NeoBase-0.34.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "68ec8e8e3224c28798e87d14327e8a3b644db966e9d552c5e8e6917418ef4b22",
"md5": "0487b33033d02793fa22434fbd13a226",
"sha256": "8b928833c12d25def67882d33c99cafc086910c8003b16bd8eb8034016549539"
},
"downloads": -1,
"filename": "neobase-0.34.3.tar.gz",
"has_sig": false,
"md5_digest": "0487b33033d02793fa22434fbd13a226",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 3968236,
"upload_time": "2025-01-13T08:11:07",
"upload_time_iso_8601": "2025-01-13T08:11:07.293147Z",
"url": "https://files.pythonhosted.org/packages/68/ec/8e8e3224c28798e87d14327e8a3b644db966e9d552c5e8e6917418ef4b22/neobase-0.34.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-13 08:11:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "alexprengere",
"github_project": "neobase",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "neobase"
}