<commit_before>from news.models import Issue, Newspaper
from Tome.helpers.data.helpers.metadatafix import getArticleFromLine,\
    getPubDate, BASE_PATH, METADATA_TITLE
from Tome.helpers.debug import Printer

DATA_BASE_PATH = BASE_PATH
DATA_TITLE = METADATA_TITLE

out = Printer()


def wipeIssues():
    Issue.objects.all().delete()


def buildIssue(pub_date, paper):
    return Issue(date_published=pub_date, newspaper_id=paper)


def importIssues():
    f = open(DATA_BASE_PATH + DATA_TITLE + '.csv')
    counter = 0
    issues = {}
    newIssues = []
    for line in f:
        article = getArticleFromLine(line, counter)
        try:
            articleDate = getPubDate(article)
        except ValueError as e:
            out.log(e)
            out.log("Invalid date at line: {0}".format(counter))
            wipeIssues()
            return
        if ((articleDate, article['paper_key']) not in issues):<commit_msg>fixed issue import<commit_after>from news.models import Issue, Newspaper
from Tome.helpers.data.helpers.metadatafix import getArticleFromLine,\
    getPubDate, METADATA_TITLE
from Tome.helpers.data.helpers.general import BASE_PATH
from Tome.helpers.debug import Printer

DATA_BASE_PATH = BASE_PATH
DATA_TITLE = METADATA_TITLE

out = Printer()


def wipeIssues():
    Issue.objects.all().delete()


def buildIssue(pub_date, paper):
    return Issue(date_published=pub_date, newspaper_id=paper)


def importIssues():
    f = open(DATA_BASE_PATH + DATA_TITLE + '.csv')
    counter = 0
    issues = {}
    newIssues = []
    for line in f:
        article = getArticleFromLine(line, counter)
        try:
            articleDate = getPubDate(article)
        except ValueError as e:
            out.log(e)
            out.log("Invalid date at line: {0}".format(counter))
            wipeIssues()
            return
        if ((articleDate, article['paper_key']) not in issues):
{'fraction_non_alphanumeric': 0.09957850368809273, 'fraction_numerical': 0.002107481559536354, 'mean_word_length': 3.075107296137339, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '3493608', 'n_tokens_mistral': 611, 'n_tokens_neox': 590, 'n_words': 142}