Skip to content

Commit

Permalink
feat: add district-code.csv file (#23).
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Mar 22, 2022
1 parent 175e7b6 commit 75f1c1d
Show file tree
Hide file tree
Showing 4 changed files with 361 additions and 0 deletions.
351 changes: 351 additions & 0 deletions packages/core/dist/district-code.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,351 @@
name,code
北京市,010
天津市,022
石家庄市,0311
保定市,0312
张家口市,0313
承德市,0314
唐山市,0315
廊坊市,0316
沧州市,0317
衡水市,0318
邢台市,0319
邯郸市,0310
秦皇岛市,0335
太原市,0351
大同市,0352
阳泉市,0353
晋中市,0354
长治市,0355
晋城市,0356
临汾市,0357
吕梁市,0358
运城市,0359
忻州市,0350
朔州市,0349
呼和浩特市,0471
包头市,0472
乌海市,0473
乌兰察布市,0474
通辽市,0475
赤峰市,0476
鄂尔多斯市,0477
巴彦淖尔市,0478
锡林郭勒盟,0479
呼伦贝尔市,0470
兴安盟,0482
阿拉善盟,0483
沈阳市,024
大连市,0411
鞍山市,0412
抚顺市,0413
本溪市,0414
丹东市,0415
锦州市,0416
营口市,0417
阜新市,0418
辽阳市,0419
铁岭市,0410
朝阳市,0421
盘锦市,0427
葫芦岛市,0429
长春市,0431
吉林市,0432
延边朝鲜族自治州,0433
四平市,0434
通化市,0435
白城市,0436
辽源市,0437
松原市,0438
白山市,0439
哈尔滨市,0451
齐齐哈尔市,0452
牡丹江市,0453
佳木斯市,0454
绥化市,0455
黑河市,0456
大兴安岭地区,0457
伊春市,0458
大庆市,0459
七台河市,0464
鸡西市,0467
鹤岗市,0468
双鸭山市,0469
上海市,021
南京市,025
镇江市,0511
苏州市,0512
南通市,0513
扬州市,0514
盐城市,0515
徐州市,0516
淮安市,0517
连云港市,0518
常州市,0519
无锡市,0510
泰州市,0523
宿迁市,0527
杭州市,0571
湖州市,0572
嘉兴市,0573
宁波市,0574
绍兴市,0575
台州市,0576
温州市,0577
丽水市,0578
金华市,0579
衢州市,0570
舟山市,0580
合肥市,0551
蚌埠市,0552
芜湖市,0553
淮南市,0554
马鞍山市,0555
安庆市,0556
宿州市,0557
阜阳市,0558
亳州市,0567
黄山市,0559
滁州市,0550
淮北市,0561
铜陵市,0562
宣城市,0563
六安市,0564
巢湖市,0565
池州市,0566
福州市,0591
厦门市,0592
宁德市,0593
莆田市,0594
泉州市,0595
漳州市,0596
龙岩市,0597
三明市,0598
南平市,0599
南昌市,0791
九江市,0792
上饶市,0793
抚州市,0794
宜春市,0795
吉安市,0796
赣州市,0797
景德镇市,0798
萍乡市,0799
新余市,0790
鹰潭市,0701
济南市,0531
青岛市,0532
淄博市,0533
德州市,0534
烟台市,0535
潍坊市,0536
济宁市,0537
泰安市,0538
临沂市,0539
菏泽市,0530
滨州市,0543
东营市,0546
威海市,0631
枣庄市,0632
日照市,0633
莱芜市,0634
聊城市,0635
郑州市,0371
安阳市,0372
新乡市,0373
许昌市,0374
平顶山市,0375
信阳市,0376
南阳市,0377
开封市,0378
洛阳市,0379
商丘市,0370
焦作市,0391
鹤壁市,0392
濮阳市,0393
周口市,0394
漯河市,0395
驻马店市,0396
三门峡市,0398
武汉市,027
鄂州市,0711
孝感市,0712
黄冈市,0713
黄石市,0714
咸宁市,0715
荆州市,0716
宜昌市,0717
恩施土家族苗族自治州,0718
十堰市,0719
神农架林区,0719
襄樊市,0710
随州市,0722
荆门市,0724
仙桃市,0728
潜江市,0728
天门市,0728
长沙市,0731
湘潭市,0731
株洲市,0731
衡阳市,0734
郴州市,0735
常德市,0736
益阳市,0737
娄底市,0738
邵阳市,0739
岳阳市,0730
湘西土家族苗族自治州,0743
张家界市,0744
怀化市,0745
永州市,0746
广州市,020
韶关市,0751
惠州市,0752
梅州市,0753
汕头市,0754
深圳市,0755
珠海市,0756
佛山市,0757
肇庆市,0758
湛江市,0759
江门市,0750
河源市,0762
清远市,0763
云浮市,0766
潮州市,0768
东莞市,0769
中山市,0760
汕尾市,0660
阳江市,0662
揭阳市,0663
茂名市,0668
南宁市,0771
崇左市,0771
柳州市,0772
来宾市,0772
桂林市,0773
梧州市,0774
贺州市,0774
玉林市,0775
贵港市,0775
百色市,0776
钦州市,0777
河池市,0778
北海市,0779
防城港市,0770
海口市,0898
三亚市,0898
重庆市,023
成都市,028
攀枝花市,0812
自贡市,0813
绵阳市,0816
南充市,0817
达州市,0818
遂宁市,0825
广安市,0826
巴中市,0827
泸州市,0830
宜宾市,0831
内江市,0832
资阳市,0832
乐山市,0833
眉山市,0833
沐川县,0833
凉山彝族自治州,0834
雅安市,0835
甘孜藏族自治州,0836
阿坝藏族羌族自治州,0837
德阳市,0838
广元市,0839
贵阳市,0851
遵义市,0852
安顺市,0853
黔南布依族苗族自治州,0854
黔东南苗族侗族自治州,0855
铜仁地区,0856
毕节地区,0857
六盘水市,0858
黔西南布依族苗族自治州,0859
昆明市,0871
大理白族自治州,0872
红河哈尼族彝族自治州,0873
曲靖市,0874
保山市,0875
文山壮族苗族自治州,0876
玉溪市,0877
楚雄彝族自治州,0878
普洱市,0879
昭通市,0870
西双版纳傣族自治州,0691
德宏傣族景颇族自治州,0692
临沧市,0883
怒江傈僳族自治州,0886
迪庆藏族自治州,0887
丽江市,0888
拉萨市,0891
日喀则地区,0892
山南地区,0893
林芝地区,0894
昌都地区,0895
那曲地区,0896
阿里地区,0897
西安市,029
延安市,0911
榆林市,0912
渭南市,0913
商洛市,0914
安康市,0915
汉中市,0916
宝鸡市,0917
铜川市,0919
兰州市,0931
定西市,0932
平凉市,0933
庆阳市,0934
金昌市,0935
武威市,0935
张掖市,0936
嘉峪关市,0937
酒泉市,0937
天水市,0938
陇南市,0939
临夏回族自治州,0930
甘南藏族自治州,0941
白银市,0943
西宁市,0971
海东地区,0972
黄南藏族自治州,0973
海南藏族自治州,0974
果洛藏族自治州,0975
玉树藏族自治州,0976
格尔木市,0979
德令哈市,0977
乌兰县,0977
都兰县,0977
天峻县,0977
海北藏族自治州,0970
银川市,0951
石嘴山市,0952
吴忠市,0953
固原市,0954
中卫市,0955
乌鲁木齐市,0991
石河子市,0993
昌吉回族自治州,0994
五家渠市,0994
吐鲁番地区,0995
巴音郭楞蒙古自治州,0996
阿克苏地区,0997
阿拉尔市,0997
喀什地区,0998
图木舒克市,0998
伊犁哈萨克自治州,0999
奎屯市,0992
克拉玛依市,0990
塔城地区,0901
哈密地区,0902
和田地区,0903
阿勒泰地区,0906
克孜勒苏柯尔克孜自治州,0908
博尔塔拉蒙古自治州,0909
1 change: 1 addition & 0 deletions packages/core/script/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ function copyToDir(source, filename, src = 'dist') {
copyToDir('town', 'town.min.json');

copyToDir('district-code', 'district-code.json');
copyToDir('district-code', 'district-code.csv');

})();
8 changes: 8 additions & 0 deletions packages/core/script/district-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ const data = fs.readFileSync('./script/district-code.txt').toString().split('\n'
})
await fs.writeFile('./dist/district-code.json', JSON.stringify(result, null, 2));
console.log(' \x1b[32;1m✔\x1b[0m 获取 <长途电话区号> 数据: ./dist/district-code.json');

// -----> 保存 district-code.csv 数据
let csvData = 'name,code\n';
[...result].forEach(dt => {
csvData += ['name', 'code'].map(name => dt[name] || '').join(',') + '\n';
});
await fs.outputFile('./dist/district-code.csv', csvData.replace(/\n$/, ''));
console.log(' \x1b[32;1m✔\x1b[0m 生成 <长途电话区号> CSV 数据: ./dist/district-code.csv');
} catch (error) {
console.log(`ERR:获取<长途电话区号>数据[]:`, error);
}
Expand Down
1 change: 1 addition & 0 deletions packages/district-code/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
district-code.json
district-code.csv
node_modules

0 comments on commit 75f1c1d

Please sign in to comment.