Skip to main content

NYC Parser

A Python utility for parsing New York City addresses and BBL (Borough-Block-Lot) values from a single line input.

Python 3.6+ Documentation Status GitHub Actions License: MIT

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

Metadata

Release files for nyc-parser 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nyc-parser 0.1.1
File Size Uploaded
nyc_parser-0.1.1.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nyc-parser 0.1.1
File Interpreter ABI Platform
nyc_parser-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.6 kB

Release files / nyc_parser-0.1.1.tar.gz

Download URL nyc_parser-0.1.1.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d18353301244c3dd9f6511a79e130417ec4cf47c12134d440476d8f4861ef529
BLAKE2b-256 checksum
How to use checksums
265f94663f1c43f7b34e44e6c0cd0400804e9802cd6b3a764c5dd4b8eae1bb72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / nyc_parser-0.1.1-py3-none-any.whl

Download URL nyc_parser-0.1.1-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
839c0fc0574b99271e823897b0c5684d99e9849f28b53dff6a87862ef849b5e2
BLAKE2b-256 checksum
How to use checksums
815172b6f673bcb3b605be4094bef56d845a85aedaf64f19f487bd6d4d80540d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page