<commit_before>import os, csv
from django.core.management.base import NoArgsCommand
from django.conf import settings

from knesset.mks.models import Member,Party
from knesset.laws.models import Vote,VoteAction
from knesset.agendas.models import Agenda, AgendaVote

class Command(NoArgsCommand):

    def handle_noargs(self, **options):
        mks = Member.objects.order_by('current_party').values('id','name','current_party')
        for agenda in Agenda.objects.all():
            f = open(os.path.join(settings.DATA_ROOT, 'agenda_%d.csv' %
                                  agenda.id), 'wt')
            csv_writer = csv.writer(f)
            header = []
            header.append('Vote id')
            header.append('Score')
            for mk in mks:
                header.append(mk['id'])
            csv_writer.writerow(header)

            for agenda_vote in AgendaVote.objects.filter(agenda=agenda):
                row = []
                row.append(agenda_vote.vote.id)
                row.append(agenda_vote.score)
                mks_for = agenda_vote.vote.get_voters_id('for')
                mks_against = agenda_vote.vote.get_voters_id('against')
                for mk in mks:
                    if mk['id'] in mks_for:<commit_msg>update agenda export to csv to contain mks names and vote titles<commit_after>import os, csv
from django.core.management.base import NoArgsCommand
from django.conf import settings

from knesset.mks.models import Member,Party
from knesset.laws.models import Vote,VoteAction
from knesset.agendas.models import Agenda, AgendaVote

class Command(NoArgsCommand):

    def handle_noargs(self, **options):
        mks = Member.objects.order_by('current_party').values('id','name','current_party')
        for agenda in Agenda.objects.all():
            f = open(os.path.join(settings.DATA_ROOT, 'agenda_%d.csv' %
                                  agenda.id), 'wt')
            csv_writer = csv.writer(f)
            header = []
            header.append('Vote id')
            header.append('Vote title')
            header.append('Score')
            for mk in mks:
                header.append('%s %d' % (mk['name'].encode('utf8'), mk['id']))
            csv_writer.writerow(header)

            for agenda_vote in AgendaVote.objects.filter(agenda=agenda):
                row = []
                row.append(agenda_vote.vote.id)
                row.append(agenda_vote.vote.title.encode('utf8'))
                row.append(agenda_vote.score)
                mks_for = agenda_vote.vote.get_voters_id('for')
                mks_against = agenda_vote.vote.get_voters_id('against')
                for mk in mks:
                    if mk['id'] in mks_for:
{'fraction_non_alphanumeric': 0.11037037037037037, 'fraction_numerical': 0.0007407407407407407, 'mean_word_length': 2.15169194865811, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5041666', 'n_tokens_mistral': 833, 'n_tokens_neox': 790, 'n_words': 158}