Giter Club home page Giter Club logo

chinacity's Introduction

Chinacity

Get the latest China cities data from official site.

China city data (version: 2015-09-30, updated on 2016-08-09)

Or you can create these data by your own, check out Usage.

Feature

  • A command line tool
  • Get the latest China cities data from Official site
  • Outputs format support JSON and CSV
  • Option to output first charactors of every word in pinyin as short name of cities, like BJS for 北京市
  • JSON format is compatible with city data of china_city gem

Installation

Add this line to your application's Gemfile:

gem 'chinacity'

And then execute:

$ bundle

Or install it yourself as:

$ gem install chinacity

Usage

Outputs China cities data in JSON format.

The format is totally compatible with https://github.com/saberma/china_city/blob/master/db/areas.json

$ chinacity > areas.json

The result looks like

{
  "province": [
    {
      "id": "110000",
      "text": "北京市"
    },
    {
      "id": "120000",
      "text": "天津市"
    },
    ...
  ],
  "city": [
    {
      "id": "110100",
      "text": "市辖区"
    },
    {
      "id": "110200",
      "text": "县"
    },
    ...
  ],
  "district": [
    {
      "id": "110101",
      "text": "东城区"
    },
    {
      "id": "110102",
      "text": "西城区"
    },
    ...
  ]
}

Outputs China cities data with short name.

$ chinacity -s > areas.json

The result looks like

{
  "province": [
    {
      "id": "110000",
      "text": "北京市",
      "short": "BJS"
    },
    {
      "id": "120000",
      "text": "天津市",
      "short": "TJS"
    },
    {
      "id": "130000",
      "text": "河北省",
      "short": "HBS"
    },
    ...
  ],
  "city": [...],
  "district": [...]
}

Outputs China cities data in CSV format.

$ chinacity -sc > areas.csv

The result looks like

id,名称,缩写,层级
110000,北京市,BJS,1
110100,市辖区,SXQ,2
110101,东城区,DCQ,3
110102,西城区,XCQ,3
110105,朝阳区,ZYQ,3
...

Full options

$ chinacity --help

Usage: chinacity [options]

options:
    -s, --short                      Short name, first charactors of every word in pinyin
    -c, --csv                        Outputs in CSV format
    -m, --minimize                   Trim spaces to minimize JSON data
    -H, --headless                   Skip outputing the head line for CSV

Dependencies

As chinacity use csv library, only Ruby 1.9+ is supported.

Contributing

  1. Fork it ( http://github.com//chinacity/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

chinacity's People

Contributors

wongyouth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.