To convert wikipedia table to csv

PHOTO EMBED

Thu Mar 18 2021 20:57:59 GMT+0000 (Coordinated Universal Time)

Saved by @randomize_first #python

import pandas as pd

def wiki_to_csv(wikiurl = str):
    tname  = link.split("/")[-1]
    tables = pd.read_html(link, header=0)

    for i in range(len(tables)):
        if not tables[i].empty:
            fname = tname + " table " + str(i)
            tables[i].to_csv(fname, sep=',')
content_copyCOPY

https://stackoverflow.com/questions/54778873/scrape-wikipedia-table-to-csv-in-python