Skip to content

Instantly share code, notes, and snippets.

View gibbbone's full-sized avatar

Giovanni Bonaccorsi gibbbone

  • Milano, Italy
View GitHub Profile
@gibbbone
gibbbone / soupget.py
Last active June 6, 2020 11:52
How to download all files with certain extensions from the same webpage with Python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function, unicode_literals)
import sys, os, argparse, time
from bs4 import BeautifulSoup
# from: https://stackoverflow.com/a/16518224/6332373
if sys.version_info >= (3,):
import urllib.request as urllib2
import urllib.parse as urlparse
@gibbbone
gibbbone / _chi2.c
Last active July 19, 2019 15:54 — forked from dfm/_chi2.c
How to wrap C code in Python (with a few fixed bugs)
#include <Python.h>
#include <numpy/arrayobject.h>
#include "chi2.h"
/* Docstrings */
static char module_docstring[] =
"This module provides an interface for calculating chi-squared using C.";
static char chi2_docstring[] =
"Calculate the chi-squared of some data given a model.";
@gibbbone
gibbbone / export_wikipedia_tables_to_pandas.py
Last active June 12, 2018 23:51 — forked from wassname/scrape_Wikipedia_tables.py
Procedure to scrape a table from wikipedia using python. Uses MediaWikiAPI to get page content. Allows for cells spanning multiple rows and/or columns. Outputs a Pandas dataframe.
# -*- coding: utf-8 -*-
"""
Procedure to scrape a table from wikipedia using python. Uses MediaWikiAPI to get page content.
Allows for cells spanning multiple rows and/or columns. Outputs a Pandas dataframe.
Page used for testing (second table in particular):
https://en.wikipedia.org/wiki/International_Phonetic_Alphabet_chart_for_English_dialects
"""
import pandas as pd