Converts Wikipedia tables to dataframes and CSVs
Project description
Takes a wikipedia URL with a table in the webpage and returns a dataframe or list of dataframes if there are multiple tables in the webpage.
Installation
pip install wikitable
Or from source:
python setup.py install
Functions
wikitable(url, to_csv=False, table_number=[None], overwrite = False, names = None) This function will scrape every table in the wikipedia URL if no table_numbers are specified.
Parameters
url: (Required) URL of the wikipedia webpage as a string.
to_csv: boolean value that saves each table to a CSV if changed to True. Default is False.
table_number: int of list of ints. The table number you want to scrape. Defaults to scrape all tables.
overwrite: boolean value that will overwrite a CSV if there is one with the same name. Default is False.
names: string or list of strings for what the CSV(s) will be named. Default names for the CSV(s) are table1.csv, table2.csv, etc…
Returns
Returns a Pandas Dataframe or a list of Pandas Dataframes if multiple tables are scraped.
Example
from wikitable import wikitable
url = ‘https://en.wikipedia.org/wiki/List_of_countries_by_literacy_rate’
df = wikitable(url, to_csv=True, overwrite=True, table_number=2)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wikitable-1.0.0.tar.gz.
File metadata
- Download URL: wikitable-1.0.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a25bf1e6b98ef0423a5d949fc207f515812523b7018e3504f32414a22b19ae8
|
|
| MD5 |
00455c3d00ac7cf0220591c12ef5c4f9
|
|
| BLAKE2b-256 |
dd999c592abe0ac69eff79e9b049090635868277be83430b5c41c56580d0f7b6
|
File details
Details for the file wikitable-1.0.0-py3-none-any.whl.
File metadata
- Download URL: wikitable-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e57405359ecaa0c06b6a6dba8e089cd9802961e5aff7898b723ba41290977aad
|
|
| MD5 |
4f9482f3d754e92b64836c0772247676
|
|
| BLAKE2b-256 |
8724023fb92661ffd82976435df458964388d741a2aa2bff7e903a047610f785
|