A parser for New York City addresses and BBL values
Project description
NYC Parser
A Python utility for parsing New York City addresses and BBL (Borough-Block-Lot) values from a single line input.
Features
- Parse NYC addresses into components (house number, street name, borough, zip)
- Support for Queens-style hyphenated house numbers
- Borough code identification from various name formats and abbreviations
- BBL (Borough-Block-Lot) parsing with or without separators
- Handling of complex addresses with descriptors (REAR, FRONT, etc.)
- Multi-word street names
Installation
pip install nyc-parser
Usage
Parsing Addresses
from nycparser import Parser
parser = Parser()
# Basic address
result = parser.address('100 Gold St, Manhattan')
print(result)
# {'PHN': '100', 'STREET': 'GOLD ST', 'BOROUGH_CODE': 1, 'BOROUGH_NAME': 'MANHATTAN', 'ZIP': None}
# With ZIP code
result = parser.address('100 Gold St, Manhattan 10038')
print(result)
# {'PHN': '100', 'STREET': 'GOLD ST', 'BOROUGH_CODE': 1, 'BOROUGH_NAME': 'MANHATTAN', 'ZIP': '10038'}
# Queens-style address with hyphenated house number
result = parser.address('74-12 35th Ave, Queens NY 11372')
print(result)
# {'PHN': '74-12', 'STREET': '35TH AVE', 'BOROUGH_CODE': 4, 'BOROUGH_NAME': 'QUEENS', 'ZIP': '11372'}
Complex Addresses
# Address with apartment
result = parser.address('100 Gold St apt 123, Manhattan')
print(result)
# {'PHN': '100', 'STREET': 'GOLD ST', 'BOROUGH_CODE': 1, 'BOROUGH_NAME': 'MANHATTAN', 'ZIP': None}
# Complex address with descriptors
result = parser.address('188-60 REAR 120 ROAD, Queens, New York, NY, USA')
print(result)
# {'PHN': '188-60', 'STREET': 'REAR 120 ROAD', 'BOROUGH_CODE': 4, 'BOROUGH_NAME': 'QUEENS', 'ZIP': None}
# Multi-word street
result = parser.address('141 FRONT MOTT STREET, Manhattan, New York, NY, USA')
print(result)
# {'PHN': '141', 'STREET': 'FRONT MOTT STREET', 'BOROUGH_CODE': 1, 'BOROUGH_NAME': 'MANHATTAN', 'ZIP': None}
Parsing BBLs
# Parse a BBL with or without special characters
result = parser.bbl('1-00438-0006')
print(result)
# {'BOROUGH_CODE': 1, 'BLOCK': 438, 'LOT': 6, 'BOROUGH_NAME': 'MANHATTAN'}
# Standard BBL format (10 digits)
result = parser.bbl('1004380006')
print(result)
# {'BOROUGH_CODE': 1, 'BLOCK': 438, 'LOT': 6, 'BOROUGH_NAME': 'MANHATTAN'}
Borough Dictionary
# Get borough code from name
borough_code = parser.borough_dict['BROOKLYN']
print(borough_code) # 3
# Get borough name from code
borough_name = parser.borough_dict_reverse[3]
print(borough_name) # 'BROOKLYN'
Documentation
Full documentation is available at nyc-parser.readthedocs.io
Contributing
Issues and PRs are welcome! Please feel free to contribute to this project.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nyc_parser-0.1.1.tar.gz.
File metadata
- Download URL: nyc_parser-0.1.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d18353301244c3dd9f6511a79e130417ec4cf47c12134d440476d8f4861ef529
|
|
| MD5 |
61b41ae6cd325802a4c1db56714f1779
|
|
| BLAKE2b-256 |
265f94663f1c43f7b34e44e6c0cd0400804e9802cd6b3a764c5dd4b8eae1bb72
|
File details
Details for the file nyc_parser-0.1.1-py3-none-any.whl.
File metadata
- Download URL: nyc_parser-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
839c0fc0574b99271e823897b0c5684d99e9849f28b53dff6a87862ef849b5e2
|
|
| MD5 |
d3c98c9acab63cf4007dacb101da0362
|
|
| BLAKE2b-256 |
815172b6f673bcb3b605be4094bef56d845a85aedaf64f19f487bd6d4d80540d
|