Giter VIP home page Giter VIP logo

e-stat's Introduction

#e-stat

Overview

Description

e-stat(政府統計の総合窓口)から情報を取得するためのライブラリです http://www.e-stat.go.jp/SG1/estat/eStatTopPortal.do

Requirement

module

  • BeautifulSoup4
  • lxml
  • pandas

file

データ取得のために利用するため以下のファイルを用意してください

  • client.json
  • id.json (統計表IDの一覧を取得するための情報を記入)
  • meta.json(メタ情報の一覧を取得するための情報を記入)
  • stat.json(統計情報の一覧を取得するための情報を記入)
{
	"appId":"サイトにて取得したappId"
}
[
	{
		"search_kind":1,
		"kw":"雇用"
	},... //検索条件をまとめて記入
]
[
	{
		"statistical_table_code":"0000041193" // 取得するメタ情報の統計表IDを記入
	}
]
[
	{
		"statistical_table_code":"0000041193" // 取得するメタ情報の統計表IDを記入
	}
]

Usage

  1. まずはじめに、このレポジトリをクローンします
git clone https://github.com/yuta-inoue/e-stat.git
  1. 次にクローンしたe-statというディレクトリへ移動します step2

  2. 必要なモジュールのインストール

pip install pandas
pip isntall BeautifulSoup4
pip install lxml
  1. データファイル作成のためのid.jsonファイルを作成 step4

  2. 統計表IDの一覧取得 step5

これでワークディレクトリ配下のstatsIdList配下に雇用.jsonが作成される step5-2

  1. 統計データの取得 step6

これでワークディレクトリ配下のstatsData配下に0000041193.csvが作成される(作成されるcsvファイルの名前は統計表IDに基づくものです)

step6-2

Example

# -*- coding:utf-8 -*-
from statslistmanager import *
def main():
statsManager = StatsListManager()
statsManager.get_id_from_json() // id.jsonの情報をもとに統計表IDの一覧を取得する
statsManager.get_meta_from_json() // meta.jsonの情報をもとにメタ情報の一覧を取得する
statsManager.get_stats_from_json() // stat.jsonの情報をもとに統計情報の一覧を取得する
if __name__ == '__main__':
main()

Error

UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

のようなエラーが出る場合は、利用しているpythonのsite-packages内のsitecustomize.pyの頭を

import os
import sys

------------------------------
import os
import sys
sys.setdefaultencoding('utf-8') # <-これを追加

と変更を加えるとおさまると思います

参考サイト

http://qiita.com/mima_ita/items/44f358dc1bc4000d365d こちらのサイトを参考にして作成しました

Author

y-ino

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.