Usage#

Installation#

Installing skillsnetwork will depend on your local lab environment:

JupyterLab#

Using the pip CLI:

$ pip install skillsnetwork

To upgrade or ensure the most recent version is installed:

$ pip install -U skillsnetwork

JupyterLite#

Using the %pip magic command:

%pip install skillsnetwork

Reading Files From URL#

Use the skillsnetwork.read() function to read files from URL to bytes:

import skillsnetwork
raw_content = await skillsnetwork.read("https://www.example.com/my/file.json")

This confirms the file was successfully read to string:

import json
content = json.loads(raw_content)

Note

To convert from bytes to str use bytes.decode().

Downloading Files From URL#

Use the skillsnetwork.download() function to download files:

import skillsnetwork
await skillsnetwork.download("https://www.example.com/my/file.json")

By default, the saved path will be printed (See the skillsnetwork.download() api to change):

Saved as './file.json'

This confirms the file is saved in your lab environment:

import json
with open("file.json") as f:
    content = json.load(f)

Preparing and Extracting Large Datasets#

Use the skillsnetwork.prepare() to manage large compressed datasets or datafiles:

import skillsnetwork
await skillsnetwork.prepare("https://www.example.com/my/images.zip")

By default, the location the extracted data is saved will be printed:

Saved to '.'

This confirms the dataset was extracted to your current working directory in your lab environment:

from pathlib import Path
for path in Path(".").iterdir():
    print(path)
./image0.jpg
./image1.jpg
./image2.jpg
./image3.jpg
./image4.jpg
...