<commit_before>#!/usr/bin/env python
import requests
import lxml.html
import pandas as pd
import sys

URL = "http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/zika-outbreak/Pages/Zika-countries-with-transmission.aspx"

columns_old = [
    "country",
    "affected_past_nine_months",
    "affected_past_two_months"
]

columns_new = [
    "country",
    "affected_past_two_months",
    "affected_past_nine_months"
]

def scrape():
    html = requests.get(URL).content
    dom = lxml.html.fromstring(html)
    table = dom.cssselect(".ms-rteTable-1")[0]
    rows = table.cssselect("tr")[1:]
    data = [ [ td.text_content()
        for td in tr.cssselect("td, th") ]
            for tr in rows ]
    df = pd.DataFrame(data, columns=columns_new)[columns_old]
    return df

if __name__ == "__main__":
    df = scrape()
    df.to_csv(sys.stdout, index=False, encoding="utf-8")
<commit_msg>Tweak ECDC scraper to strip whitespace<commit_after>#!/usr/bin/env python
import requests
import lxml.html
import pandas as pd
import sys

URL = "http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/zika-outbreak/Pages/Zika-countries-with-transmission.aspx"

columns_old = [
    "country",
    "affected_past_nine_months",
    "affected_past_two_months"
]

columns_new = [
    "country",
    "affected_past_two_months",
    "affected_past_nine_months"
]

def scrape():
    html = requests.get(URL).content
    dom = lxml.html.fromstring(html)
    table = dom.cssselect(".ms-rteTable-1")[0]
    rows = table.cssselect("tr")[1:]
    data = [ [ td.text_content().strip()
        for td in tr.cssselect("td, th") ]
            for tr in rows ]
    df = pd.DataFrame(data, columns=columns_new)[columns_old]
    return df

if __name__ == "__main__":
    df = scrape()
    df.to_csv(sys.stdout, index=False, encoding="utf-8")

{'fraction_non_alphanumeric': 0.13813979086406164, 'fraction_numerical': 0.004402861860209136, 'mean_word_length': 3.6025316455696204, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7560050', 'n_tokens_mistral': 701, 'n_tokens_neox': 653, 'n_words': 117}