import requests
import zipfile
import io


def get_files(code):
    """
    A wrapper function to obtain .csv files from the world bank.
    
    Parameters:
    -----------
    code: str
        The code of the indicator.

    Returns:
    --------
    str
        downloaded .csv filename    
    """
    r = requests.get('http://api.worldbank.org/v2/en/indicator/' + code + '?downloadformat=csv', stream=True)
    with zipfile.ZipFile(io.BytesIO(r.content)) as z:
        filename = z.namelist()[1]
        z.extract(filename, '../data/raw_data')
        return filename