This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
from datetime import datetime | |
# make an example | |
np.random.seed(0) | |
item = np.random.choice(['A', 'B'], 10) | |
year = np.random.choice([2016, 2017], 10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instruct the interpreter to create a network request and create an object representing the request state. This can be done using the urllib module. | |
import urllib.request | |
import tarfile | |
thetarfile = "http://file.tar.gz" | |
ftpstream = urllib.request.urlopen(thetarfile) | |
thetarfile = tarfile.open(fileobj=ftpstream, mode="r|gz") | |
thetarfile.extractall() | |
# The ftpstream object is a file-like that represents the connection to the ftp server. Then the tarfile module can access this stream. Since we do not pass the filename, we have to specify the compression in the mode parameter. |