<commit_before>import csv
import os
import requests


def download_ladder_csv(league):
    ''' Downloads the entire ladder for a league in CSV format. Takes around 6
    seconds on average, which is faster than pulling the ladder from the API
    sequentially (75 seconds) or concurrently (20 seconds). The downside is
    that CSV ladder data does not include Twitch information or challenge
    completion information.

    CSV format:

        LoginStatus,Rank,Account,Character,Class,Level,Experience,Dead

    :param league: League for which to retrieve the ladder CSV
    :return: None (writes to file)
    '''
    base_url = 'http://www.pathofexile.com/ladder/export-csv/league/%s/index/1'
    url = base_url % league
    cache_dir = '.ladder_cache'
    csv_file = '%s/%s.csv' % (cache_dir, league.replace(' ', ''))
    r = requests.get(url)
    if not os.path.exists(cache_dir):
        os.mkdir(cache_dir)
    with open(csv_file, 'w') as f:
        f.write(r.content)


def main():
    download_ladder_csv('Standard')

if __name__ == '__main__':
    main()<commit_msg>cleans up code<commit_after>import csv
import os
import requests


def download_ladder_csv(league):
    ''' Downloads the entire ladder for a league in CSV format. Takes around 6
    seconds on average, which is faster than pulling the ladder from the API
    sequentially (75 seconds) or concurrently (20 seconds). The downside is
    that CSV ladder data does not include Twitch information or challenge
    completion information.

    CSV format:

        LoginStatus,Rank,Account,Character,Class,Level,Experience,Dead

    :param league: League for which to retrieve the ladder CSV
    :return: None (writes to file)
    '''
    base_url = 'http://www.pathofexile.com/ladder/export-csv/league/%s/index/1'
    url = base_url % league
    cache_dir = '.ladder_cache'
    csv_file = '%s/%s.csv' % (cache_dir, league.replace(' ', ''))
    r = requests.get(url)
    if not os.path.exists(cache_dir):
        os.mkdir(cache_dir)
    with open(csv_file, 'w') as f:
        f.write(r.content)
{'fraction_non_alphanumeric': 0.10067763794772508, 'fraction_numerical': 0.005808325266214908, 'mean_word_length': 3.3792372881355934, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3917943', 'n_tokens_mistral': 657, 'n_tokens_neox': 621, 'n_words': 204}