INNER CODE UNIT · Python

save_smith_book

aeturrell/coding-for-economists · data_set_prep.py:60

def save_smith_book():
    """Downloads part of the 'The Wealth of Nations' and saves it."""
    html = urllib.request.urlopen(
        "https://www.gutenberg.org/files/3300/3300-h/3300-h.htm"
    ).read()
    # Take the book text only
    book_text = (
        text_from_html(html)
        .split("Produced by Colin Muir, and David Widger")[1]
        .split("Conclusion of the Chapter.")[0]
    )
    print(book_text.split("\n")[0])
    open(os.path.join("data", "smith_won.txt"), "w").write(book_text)


def prep_river_data():
    """
    Download the 10m rivers, lakes, and centerlines from and put in scratch/rivers/

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…