mirror of
https://github.com/captn3m0/india-pincode-regex.git
synced 2024-09-13 13:47:35 +00:00
Minor updates
This commit is contained in:
parent
062df76ec9
commit
dc6531ee98
@ -2,7 +2,7 @@ root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
# indent_size = 2
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -18,3 +18,6 @@ __pycache__/
|
||||
Gemfile.lock
|
||||
*.gem
|
||||
*.csv
|
||||
.pdm.toml
|
||||
__pypackages__/
|
||||
src/pincode.egg-info/
|
||||
|
11
CHANGELOG.md
Normal file
11
CHANGELOG.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [UNRELEASED][unreleased]
|
||||
|
||||
## [1.0.5][1.0.5]
|
||||
##
|
||||
|
||||
[1.0.5]: https://github.com/captn3m0/india-pincode-regex/releases/tag/1.0.5
|
@ -1,6 +1,6 @@
|
||||
# Generating the regex
|
||||
|
||||
1. Download the latest CSV file from <https://data.gov.in/node/85839/download> or <https://data.gov.in/resources/all-india-pincode-directory>.
|
||||
1. Download the latest CSV file from <https://data.gov.in/resources/all-india-pincode-directory-till-last-month>.
|
||||
2. Copy all the pincodes to a pincodes.txt file
|
||||
3. Generate all unique pincodes by running `sort -u pincodes.txt > /tmp/pin.txt`
|
||||
4. `npm install`
|
||||
|
11
Pipfile
11
Pipfile
@ -1,11 +0,0 @@
|
||||
[[source]]
|
||||
name = "pypi"
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3.5"
|
@ -9,26 +9,30 @@ if (!process.argv[2]) {
|
||||
|
||||
const readInterface = readline.createInterface({
|
||||
input: fs.createReadStream(process.argv[2]),
|
||||
console: false
|
||||
console: false,
|
||||
});
|
||||
|
||||
regexes = [];
|
||||
|
||||
// There are 3 Pincodes that start with 9, but we
|
||||
// ignore those as test offices.
|
||||
for (var i = 0; i < 8; i++) {
|
||||
regexes.push(new Trie());
|
||||
}
|
||||
|
||||
readInterface.on("line", function(line) {
|
||||
readInterface.on("line", function (line) {
|
||||
if (line.length === 6) {
|
||||
// First character of the PIN
|
||||
let areaCode = parseInt(line.charAt(0), 10);
|
||||
let areaCodeIndex = areaCode - 1;
|
||||
regexes[areaCodeIndex].add(line);
|
||||
if (areaCode < 9 && areaCode > 0) {
|
||||
let areaCodeIndex = areaCode - 1;
|
||||
regexes[areaCodeIndex].add(line);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
readInterface.on("close", function() {
|
||||
for(i in regexes) {
|
||||
readInterface.on("close", function () {
|
||||
for (i in regexes) {
|
||||
console.log(regexes[i].toRegExp());
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user