--- title: Common utils keywords: fastai sidebar: home_sidebar summary: "A collection of utilities often used." description: "A collection of utilities often used." nb_path: "nbs/utils/common_utils.ipynb" ---
{% raw %}
{% endraw %} {% raw %}
{% endraw %}

Download

{% raw %}

wget_download[source]

wget_download(url, savepath)

{% endraw %} {% raw %}
{% endraw %} {% raw %}

download_url[source]

download_url(url:str, folder:str, log:bool=True)

Downloads the content of an URL to a specific folder. Args: url (string): The url. folder (string): The folder. log (bool, optional): If :obj:False, will not print anything to the console. (default: :obj:True)

{% endraw %} {% raw %}
{% endraw %} {% raw %}
download_url('https://files.grouplens.org/datasets/movielens/ml-1m.zip',
             './data/bronze')
Downloading https://files.grouplens.org/datasets/movielens/ml-1m.zip
'./data/bronze/ml-1m.zip'
{% endraw %} {% raw %}
!tree ./data
./data
└── bronze
    └── ml-1m.zip

1 directory, 1 file
{% endraw %} {% raw %}
!tree --du -h -C ./data
./data
├── [ 24M]  bronze
│   └── [ 24M]  ml-1m
│       ├── [167K]  movies.dat
│       ├── [ 23M]  ratings.dat
│       ├── [5.4K]  README
│       └── [131K]  users.dat
└── [3.0M]  silver
    └── [3.0M]  ml-1m_min_rating0-min_uc5-min_sc5-splitleave_one_out
        └── [3.0M]  dataset.pkl

  27M used in 4 directories, 5 files
{% endraw %}

Extract

{% raw %}

extract_tar[source]

extract_tar(path:str, folder:str, mode:str='r:gz', log:bool=True)

Extracts a tar archive to a specific folder. Args: path (string): The path to the tar archive. folder (string): The folder. mode (string, optional): The compression mode. (default: :obj:"r:gz") log (bool, optional): If :obj:False, will not print anything to the console. (default: :obj:True)

{% endraw %} {% raw %}
{% endraw %} {% raw %}

extract_zip[source]

extract_zip(path:str, folder:str, log:bool=True)

Extracts a zip archive to a specific folder. Args: path (string): The path to the tar archive. folder (string): The folder. log (bool, optional): If :obj:False, will not print anything to the console. (default: :obj:True)

{% endraw %} {% raw %}
{% endraw %} {% raw %}

extract_bz2[source]

extract_bz2(path:str, folder:str, log:bool=True)

Extracts a bz2 archive to a specific folder. Args: path (string): The path to the tar archive. folder (string): The folder. log (bool, optional): If :obj:False, will not print anything to the console. (default: :obj:True)

{% endraw %} {% raw %}
{% endraw %} {% raw %}

extract_gz[source]

extract_gz(path:str, folder:str, log:bool=True)

Extracts a gz archive to a specific folder. Args: path (string): The path to the tar archive. folder (string): The folder. log (bool, optional): If :obj:False, will not print anything to the console. (default: :obj:True)

{% endraw %} {% raw %}
{% endraw %}