#!runscript

import popvox.models as pv
import unicodedata

users = pv.UserProfile.objects.all()
with open("/tmp/userdata.csv",'w') as f:
    for userobj in users:
        datastr = unicodedata.normalize('NFKD',userobj.user.username).encode('ascii','ignore')+", "+ str(userobj.user.email)+", "+str(userobj.user.date_joined)
        comments = pv.UserComment.objects.filter(user=userobj)
        if comments:
            lastcomment = pv.UserComment.objects.filter(user=userobj).latest('created')
            state = lastcomment.state
            dist = lastcomment.congressionaldistrict
            statedist = state+"-"+str(dist)
            datastr += ", "+statedist
            for comment in comments:
                bill = pv.Bill.objects.get(id=comment.bill_id)
                billtype = bill.billtype
                billnumber = bill.billnumber
                billnum = billtype+"-"+str(billnumber)
                commentdate = comment.created
                position = comment.position
                datastr += ", "+billnum+", "+str(position)+", "+str(commentdate)
        f.write(datastr+"\n")
cf28813f2c89f3bac465b0083f84e9d68457ccc4
<mask token>

<mask token>
with open('/tmp/userdata.csv', 'w') as f:
    for userobj in users:
        datastr = unicodedata.normalize('NFKD', userobj.user.username).encode(
            'ascii', 'ignore') + ', ' + str(userobj.user.email) + ', ' + str(
            userobj.user.date_joined)
        comments = pv.UserComment.objects.filter(user=userobj)
        if comments:
            lastcomment = pv.UserComment.objects.filter(user=userobj).latest(
                'created')
            state = lastcomment.state
            dist = lastcomment.congressionaldistrict
            statedist = state + '-' + str(dist)
            datastr += ', ' + statedist
            for comment in comments:
                bill = pv.Bill.objects.get(id=comment.bill_id)
                billtype = bill.billtype
                billnumber = bill.billnumber
                billnum = billtype + '-' + str(billnumber)
                commentdate = comment.created
                position = comment.position
                datastr += ', ' + billnum + ', ' + str(position) + ', ' + str(
                    commentdate)
        f.write(datastr + '\n')

<mask token>
users = pv.UserProfile.objects.all()
with open('/tmp/userdata.csv', 'w') as f:
    for userobj in users:
        datastr = unicodedata.normalize('NFKD', userobj.user.username).encode(
            'ascii', 'ignore') + ', ' + str(userobj.user.email) + ', ' + str(
            userobj.user.date_joined)
        comments = pv.UserComment.objects.filter(user=userobj)
        if comments:
            lastcomment = pv.UserComment.objects.filter(user=userobj).latest(
                'created')
            state = lastcomment.state
            dist = lastcomment.congressionaldistrict
            statedist = state + '-' + str(dist)
            datastr += ', ' + statedist
            for comment in comments:
                bill = pv.Bill.objects.get(id=comment.bill_id)
                billtype = bill.billtype
                billnumber = bill.billnumber
                billnum = billtype + '-' + str(billnumber)
                commentdate = comment.created
                position = comment.position
                datastr += ', ' + billnum + ', ' + str(position) + ', ' + str(
                    commentdate)
        f.write(datastr + '\n')

import popvox.models as pv
import unicodedata
users = pv.UserProfile.objects.all()
with open('/tmp/userdata.csv', 'w') as f:
    for userobj in users:
        datastr = unicodedata.normalize('NFKD', userobj.user.username).encode(
            'ascii', 'ignore') + ', ' + str(userobj.user.email) + ', ' + str(
            userobj.user.date_joined)
        comments = pv.UserComment.objects.filter(user=userobj)
        if comments:
            lastcomment = pv.UserComment.objects.filter(user=userobj).latest(
                'created')
            state = lastcomment.state
            dist = lastcomment.congressionaldistrict
            statedist = state + '-' + str(dist)
            datastr += ', ' + statedist
            for comment in comments:
                bill = pv.Bill.objects.get(id=comment.bill_id)
                billtype = bill.billtype
                billnumber = bill.billnumber
                billnum = billtype + '-' + str(billnumber)
                commentdate = comment.created
                position = comment.position
                datastr += ', ' + billnum + ', ' + str(position) + ', ' + str(
                    commentdate)
        f.write(datastr + '\n')

#!runscript

import popvox.models as pv
import unicodedata

users = pv.UserProfile.objects.all()
with open("/tmp/userdata.csv",'w') as f:
    for userobj in users:
        datastr = unicodedata.normalize('NFKD',userobj.user.username).encode('ascii','ignore')+", "+ str(userobj.user.email)+", "+str(userobj.user.date_joined)
        comments = pv.UserComment.objects.filter(user=userobj)
        if comments:
            lastcomment = pv.UserComment.objects.filter(user=userobj).latest('created')
            state = lastcomment.state
            dist = lastcomment.congressionaldistrict
            statedist = state+"-"+str(dist)
            datastr += ", "+statedist
            for comment in comments:
                bill = pv.Bill.objects.get(id=comment.bill_id)
                billtype = bill.billtype
                billnumber = bill.billnumber
                billnum = billtype+"-"+str(billnumber)
                commentdate = comment.created
                position = comment.position
                datastr += ", "+billnum+", "+str(position)+", "+str(commentdate)
        f.write(datastr+"\n")