GithubHelp home page GithubHelp logo

pushkardakle / wikitables Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bcicen/wikitables

0.0 2.0 0.0 27 KB

Import tables from any Wikipedia article as a dataset in Python

License: MIT License

Python 100.00%

wikitables's Introduction

wikitables

Documentation Status PyPI version

Import tables from any Wikipedia article as a dataset in Python

Installing

pip install wikitables

Usage

Importing all tables from a given article:

from wikitables import import_tables
tables = import_tables('List of cities in Italy') #returns a list of WikiTable objects

To import an article from a different language, simply add the Wikipedia language code as an argument to import_tables

tables = import_tables('İtalya\'daki_şehirler_listesi', 'tr') #returns a list of WikiTable objects

Iterate over a table's rows:

print(tables[0].name)
for row in tables[0].rows:
    print('{City}: {Area(km2)}'.format(**row))

output:

List of cities in Italy[0]
Milan: 4,450.11
Naples: 3,116.52
Rome: 3,340.41
Turin: 1,328.40
...

Or return the table encoded as JSON:

tables[0].json()

output:

[
    {
        "City": "Milan",
        "Population January 1, 2014": "6,623,798",
        "Density(inh./km2)": "1,488",
        "Area(km2)": "4,450.11"
    },
    {
        "City": "Naples",
        "Population January 1, 2014": "5,294,546",
        "Density(inh./km2)": "1,699",
        "Area(km2)": "3,116.52"
    },
    ...

Full documentation available here

Roadmap

Some planned and wishlist features:

  • Type guesing from MediaWiki template values

wikitables's People

Contributors

bcicen avatar mayhewsw avatar lucassimonelli avatar martinthoma avatar kmario23 avatar

Watchers

James Cloos avatar Pushkar Dakle 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.