Skip to content

Commit 9e63ba0

Browse files
committed
Merge remote-tracking branch 'upstream/main' into feature/analytics-dashboard
2 parents a62f63f + 1c07228 commit 9e63ba0

1 file changed

Lines changed: 96 additions & 22 deletions

File tree

README.md

Lines changed: 96 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,122 @@
1-
# Postal Regex
21

3-
A community-maintained repository of postal/ZIP code regex patterns for 50+ countries.
4-
This package is ideal for **form validation, data cleaning, and big data applications**.
2+
# Postal Regex 📨
3+
4+
[![PyPI version](https://img.shields.io/pypi/v/postal-regex.svg)](https://pypi.org/project/postal-regex/)
5+
[![License](https://img.shields.io/pypi/l/postal-regex)](LICENSE)
6+
[![Build Status](https://github.com/ankitgadling/postal-regex/actions/workflows/ci.yml/badge.svg)](https://github.com/ankitgadling/postal-regex/actions)
7+
8+
---
9+
10+
A community-maintained repository of postal/ZIP code regex patterns for 50+ countries.
11+
Ideal for **form validation, data cleaning, and big data applications**.
12+
13+
---
14+
15+
## Table of Contents
16+
17+
- [Features](#features)
18+
- [Installation](#installation)
19+
- [Usage](#usage)
20+
- [Big Data Support](#big-data-support)
21+
- [Contributing](#contributing)
22+
- [License](#license)
523

624
---
725

826
## Features
927

1028
- ✅ 50+ countries included, with postal code regex patterns
11-
- ✅ Supports lookup by **country code** or **country name**
12-
- ✅ Precompiled regex for fast validation in Python
13-
- ✅ JSON schema ensures consistent data structure
14-
- ✅ Ready for **big data frameworks** like Spark, Dask, or Pandas
29+
- ✅ Validate postal codes by **country code** or **country name**
30+
```python
31+
from postal_regex.core import validate
32+
33+
validate("IN", "110001") # True
34+
validate("India", "110001") # True
35+
validate("US", "12345-6789") # True
36+
````
37+
38+
* ✅ Normalize country identifiers
39+
40+
```python
41+
from postal_regex.core import normalize
42+
43+
normalize("United States") # "US"
44+
normalize("India") # "IN"
45+
```
46+
47+
* ✅ Works with **Pandas and Spark DataFrames**
48+
49+
```python
50+
import pandas as pd
51+
from postal_regex.bulk import validate_dataframe
52+
53+
df = pd.DataFrame({"country": ["US", "FR"], "postal_code": ["90210", "75001"]})
54+
df_validated = validate_dataframe(df, country_col="country", postal_col="postal_code")
55+
print(df_validated)
56+
```
57+
58+
* ✅ JSON schema ensures consistent data structure
59+
* ✅ Precompiled regex for fast Python validation
1560

1661
---
62+
1763
## Installation
1864

1965
```bash
2066
pip install postal-regex
2167
```
2268

23-
## Usage
69+
For development:
2470

2571
```bash
26-
from postal_regex.core import validate, normalize, get_supported_countries
72+
git clone https://github.com/ankitgadling/postal-regex.git
73+
cd postal-regex
74+
pip install -e .
75+
```
2776

28-
# Validate postal codes
29-
validate("IN", "110001") # True
30-
validate("India", "110001") # True
31-
validate("US", "12345-6789") # True
77+
---
78+
79+
## Big Data Support
3280

33-
# Normalize country identifiers
34-
normalize("India") # "IN"
35-
normalize("US") # "US"
81+
Validate postal codes in **large datasets** with Spark or Pandas.
3682

37-
# List all supported countries
38-
get_supported_countries()
39-
# [{'code': 'IN', 'name': 'India'}, {'code': 'US', 'name': 'United States'}, ...]
83+
### Spark Example
4084

85+
```python
86+
from pyspark.sql import SparkSession
87+
from postal_regex.bulk import validate_spark_dataframe
88+
89+
spark = SparkSession.builder.getOrCreate()
90+
df = spark.createDataFrame([
91+
{"country": "FR", "postal_code": "75001"},
92+
{"country": "DE", "postal_code": "10115"}
93+
])
94+
df_validated = validate_spark_dataframe(df, country_col="country", postal_col="postal_code")
95+
df_validated.show()
4196
```
97+
98+
### Pandas Example
99+
100+
```python
101+
import pandas as pd
102+
from postal_regex.bulk import validate_dataframe
103+
104+
df = pd.DataFrame({
105+
"country": ["FR", "DE"],
106+
"postal_code": ["75001", "10115"]
107+
})
108+
df_validated = validate_dataframe(df, country_col="country", postal_col="postal_code")
109+
print(df_validated)
110+
```
111+
42112
---
43113

44-
## Contributors
114+
## Contributing
115+
116+
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
117+
118+
---
45119

46-
[![Contributors](https://contrib.rocks/image?repo=ankitgadling/postal-regex)](https://github.com/ankitgadling/postal-regex/graphs/contributors)
120+
## License
47121

48-
---
122+
MIT License. See [LICENSE](LICENSE) for details.

0 commit comments

Comments
 (0)